我正在"翻译"NUnit测试到Visual Studios单元测试,我想知道[ClassInitialize()]VS中的属性是否等同[SetUp()]于NUnit?
我不能让以下XAML按我的意愿工作.所有绑定都起作用,因为绑定没有错误.但是我没有从RatioShape矩形的绑定中获得预期的结果.问题是附加属性wpflib:RatioPanel.Ratio始终返回其默认值,而不是数据绑定值.
所以我认为RatioShape上的附加属性设置在错误的"上下文"中.如何绑定到附加属性,以便wpflib:RatioPanel获取绑定值?
<wpflib:RatioContentPresenter2 RatioMaxValue="{Binding Path=RatioMaxValue}">
<ItemsControl Grid.Row="0" wpflib:RatioContentPresenter2.RatioOffset="{Binding Path=RatioOffset}" wpflib:RatioContentPresenter2.RatioValue="{Binding Path=RatioValue}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<wpflib:RatioPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Rectangle x:Name="RatioShape" wpflib:RatioPanel.Ratio="{Binding Path=Value}" Fill="{Binding Path=Brush}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsSource>
<Binding Path="RatioItems" Mode="OneWay" />
</ItemsControl.ItemsSource>
</ItemsControl>
</wpflib:RatioContentPresenter2>
Run Code Online (Sandbox Code Playgroud)