【问题标题】:How to fill DockPanel With one control如何用一个控件填充 DockPanel
【发布时间】:2014-11-04 16:08:01
【问题描述】:

我想让gridview 填充dockpanel。我有 LastChildFill="True" 但它仍然没有填满窗口。我在顶部有一个网格,其中包含一个标签和文本框。然后是我想要填充其余空间的停靠面板。然后插入该停靠面板,我希望 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>

【问题讨论】:

    标签: c# xaml dockpanel


    【解决方案1】:

    我不确定,但最好将您的 DockPanel 替换为 Grid。然后把你的DataGrid 放在这个网格的中心。将DataGrid 的高度和宽度设置为自动。我想这就是你想要的。

    【讨论】:

      猜你喜欢
      • 2021-05-13
      • 2010-11-08
      • 2013-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-06
      • 2016-12-02
      相关资源
      最近更新 更多