Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF/XAML中自动生成的DataGrid的布局问题_Wpf_Xaml_Layout - Fatal编程技术网

WPF/XAML中自动生成的DataGrid的布局问题

WPF/XAML中自动生成的DataGrid的布局问题,wpf,xaml,layout,Wpf,Xaml,Layout,我对WPF/XAML有问题。我不知道如何让左侧网格(内部有一个居中的图像和背景颜色)根据右侧数据网格上自动生成的高度来增加其高度 它们都显示在全局网格中。如果我在相应的行上设置了固定高度,自动生成的datagrid将显示一条垂直线,具体取决于我之前设置的固定行高度 过程 --这里有些东西 请分享您的xaml代码我认为这里的主要混淆点可能是左侧网格比右侧网格大。图像的边距+高度为94@YotamS。右边的datagrid比左边的网格更大。我相信减小边距会导致#1上的左边按钮更高(如果您正试图

我对WPF/XAML有问题。我不知道如何让左侧网格(内部有一个居中的图像和背景颜色)根据右侧数据网格上自动生成的高度来增加其高度

它们都显示在全局网格中。如果我在相应的行上设置了固定高度,自动生成的datagrid将显示一条垂直线,具体取决于我之前设置的固定行高度


过程
--这里有些东西

请分享您的xaml代码我认为这里的主要混淆点可能是左侧网格比右侧网格大。图像的边距+高度为94@YotamS。右边的datagrid比左边的网格更大。我相信减小边距会导致#1上的左边按钮更高(如果您正试图实现这一点的话)。您可以在DataGrid上设置一个MinHight,以确保不会发生#2。左侧网格上的高度已经自动增长,因为网格的默认行为是拉伸填充。您可以在图1中看到结果。左栅格不会随着从右栅格自动生成的高栅格一起上升。我希望左侧的网格以其背景(灰色)填充整个空间,内部图像在考虑整个高度的情况下更加居中
<!--ElementR0C1-->
<Grid Name="test">
    <Grid.RowDefinitions>
        <RowDefinition Height="30"/>
        <RowDefinition Height="auto"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <!--Width ElementsC1-->
        <ColumnDefinition Width="160"/>
        <ColumnDefinition Width="20"/>
        <ColumnDefinition Width="500"/>
    </Grid.ColumnDefinitions>
    <!--START-->
    <Label Grid.Row="0" Grid.Column="0" Style="{StaticResource L1}" VerticalAlignment="Top">Process</Label>
    <Grid Grid.Row="1" Grid.Column="0" Background="DDDDDD">
        <Image Margin="0,30,0,0" Height="64" Width="64" Source="../../Resources/ok.png" Name="imgJobs" VerticalAlignment="Center" HorizontalAlignment="Center"/>
    </Grid>
    <DataGrid x:Name="grdJobs" Grid.Row="0" Grid.Column="2" Grid.RowSpan="2" Width="500">
-- some stuff here
    </DataGrid>
</Grid>