我想让gridview填充dockpanel。我有LastChildFill =“True”但它仍然没有填满窗口。我的顶部有一个网格,上面有一个标签和文本框。然后我想要填充其余空间的dockpanel。然后insode那个停靠面板,我想让Gridview填充那个空间。 继承人我所拥有的:
<Window x:Class="DocumentHandlingTouch.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MultitouchHOL" Height="394" Width="633" WindowState="Maximized"
xmlns:mt="clr-namespace:DocumentHandlingTouch" Icon="/DocumentHandlingTouch;component/1414781821_143818.ico">
<Canvas Name="_canvas">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Replace with your UserControl -->
<Label Canvas.Left="221" Canvas.Top="0" Content="Item #" Height="28" Name="label1" Grid.Column="1" Grid.Row="1" FontWeight="Bold" />
<TextBox Name="TxtItemNumber" Width="220" Grid.Column="2" Grid.Row="1" Background="#FFF5F5CC" />
</Grid>
<DockPanel Canvas.Left="0" Canvas.Top="34" Name="dockPanel1" LastChildFill="True">
<DataGrid AutoGenerateColumns="False" Name="DGVImages" SelectionChanged="DGVImages_SelectionChanged" Height="324" Width="612" />
</DockPanel>
</Canvas>
</Window>
答案 0 :(得分:0)
我不确定,但最好只用DockPanel
替换Grid
。然后将DataGrid
放在此网格的中心。将DataGrid
的高度和宽度设置为自动。而且我认为这就是你想要的。