所以我观察到一些我无法解释自己的奇怪行为。我有以下UserControl:
<Grid Grid.Column="0" Margin="50 25 50 25">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding DataContext.SetcardTitle, RelativeSource={RelativeSource AncestorType={x:Type local:MainWindowEditor}}}" Style="{StaticResource editorLabelStyle}"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Border Grid.Row="1" BorderBrush="{DynamicResource AccentBaseColorBrush}" BorderThickness="3" >
<xctk:Zoombox x:Name="zoombox" Style="{StaticResource editorZoomboxStyle}" >
<Canvas x:Name="myCanvas" HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="True" Width="{Binding LiveImage.ViewablePicture.Width}" Height="{Binding LiveImage.ViewablePicture.Height}">
<Canvas.Background>
<ImageBrush ImageSource="{Binding LiveImage.ViewablePicture}"/>
</Canvas.Background>
<Rectangle Stroke="Cyan" StrokeThickness="3" RadiusX="100000" RadiusY="1000000" Width="{Binding ROI.Width}" Height="{Binding ROI.Height}" Canvas.Left="{Binding ROI.X}" Canvas.Top="{Binding ROI.Y}"/>
</Canvas>
</xctk:Zoombox>
</Border>
<ListBox Grid.Row="2" Grid.ColumnSpan="2" MinHeight="100" Margin="0 10 0 0" ItemsSource="{Binding Images, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" ItemTemplate="{StaticResource imagesListItemStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid>
像这样运行应用程序会在加载usercontrol时导致以下异常(第一行说:Width和Height必须为非负数):
为防止出现此异常,我必须完全删除标签内容的绑定。
有人知道这里发生了什么吗?
修改 看起来,扩展WPF工具包中的某些内容已引起更改。我回到了较旧的版本,该版本的所有功能均正常运行。