获取嵌套DataGrid行以填充内部Datagrid

时间:2015-07-30 19:44:34

标签: c# wpf datagrid

我在另一个datagrids列中有一个嵌套的datagrid,如下图所示。此列是“初始/日期”列。

1] 我希望内部数据网格底行将内部数据网格填充到与外部数据网格行高相同的大小,以便填充内部数据网格底部的灰色区域。

我尝试过以下代码,但不起作用:

        <Style x:Key="DataGrid" TargetType="{x:Type DataGridRow}">
        <Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}, AncestorLevel=2},Path=ActualHeight}"/>
    </Style>

我怎样才能填充灰色区域并且柱分割器也填充到底部?

谢谢Callum

1 个答案:

答案 0 :(得分:0)

我自己设法找到了解决方案。我创建了一个带有边框的背景图像,因为我将2列的宽度设置为50%,并将此背景作为资源添加到我的项目中。我还将datagrid上的borderbrush设置为transparent,并将gridlinesvisibility设置为none并添加以下代码:

<DataGrid.Background>
                                <ImageBrush ImageSource="Images/Background.png"/>
                            </DataGrid.Background>
                            <DataGrid.RowStyle>
                                <Style TargetType="{x:Type DataGridRow}">
                                    <Setter Property="Background" Value="Transparent"/>
                                </Style>
                            </DataGrid.RowStyle>

干杯Callum

相关问题