我在 WPF 用户控件中有以下标记:
<Border Name="_border" BorderThickness="4" BorderBrush="Blue">
<Canvas Name="_canvas" Background="Black" >
<DockPanel LastChildFill="True">
<ItemsControl Name="_itemsControl" Background="Bisque" AllowDrop="True" Height="100" Width="100"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemTemplate="{StaticResource pictureTemplate}"
ItemsPanel="{StaticResource panelTemplate}"
Drop="_itemsControl_Drop"
DragOver="_itemsControl_DragOver"
DragLeave="_itemsControl_DragLeave"
PreviewMouseLeftButtonDown="_itemsControl_PreviewMouseLeftButtonDown"
PreviewMouseMove="_itemsControl_PreviewMouseMove">
</ItemsControl>
</DockPanel>
</Canvas>
</Border>
我希望 ItemsControl 填充所有可用空间,但它不遵守 DockPanel 的 LastChildFill 属性。水平和垂直“拉伸”值也无济于事。我错过了什么?