【问题标题】:Get Nested DataGrid Rows to fill inner Datagrid获取嵌套的 DataGrid 行以填充内部 Datagrid
【发布时间】:2015-07-30 19:44:33
【问题描述】:

我在另一个数据网格列中有一个嵌套数据网格,如下图所示。此列是初始/日期列。

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

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

        <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>

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

感谢卡勒姆

【问题讨论】:

    标签: c# wpf datagrid


    【解决方案1】:

    我自己设法找到了解决这个问题的方法。我创建了一个背景图像,其中心有一个边框,因为我已将 2 列的宽度设置为 50%,并将此背景作为资源添加到我的项目中。我还将datagrid上的borderbrush设置为透明并将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>
    

    干杯卡勒姆

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-18
      • 2020-12-10
      • 1970-01-01
      • 1970-01-01
      • 2014-09-11
      • 2014-03-03
      • 2017-05-20
      • 1970-01-01
      相关资源
      最近更新 更多