首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数据网格单元格中的数据网格

数据网格单元格中的数据网格
EN

Stack Overflow用户
提问于 2010-07-07 13:49:34
回答 1查看 286关注 0票数 1

嘿,我怎么才能把一个数据网格放在其他数据网格单元格4ex中-我有一个带有折叠符号(或按钮)的cutomer colum,现在当我点击这个符号(或按钮)时,新的数据网格会在同一行上轮询,下一列有客户详细信息。

有谁能指出如何做到这一点吗?

EN

回答 1

Stack Overflow用户

发布于 2010-07-14 17:18:51

很简单..。

代码语言:javascript
复制
public partial class Window1 : Window
    {
        DataTable dt = new DataTable();
        public Window1()
        {
            InitializeComponent();
            dt.Columns.Add("AA", typeof(string));
            dt.Columns.Add("BB", typeof(string));
            dt.Columns.Add("CC", typeof(string));
            dt.Rows.Add("11", "22");
            dt.Rows.Add("22", "33");
            dt.Rows.Add("33", "44");
            dataGrid1.ItemsSource = dt.DefaultView;
            this.dataGrid1.RowDetailsVisibilityChanged += new EventHandler<Microsoft.Windows.Controls.DataGridRowDetailsEventArgs>(datagrid1_RowdetailsVisibilityChanged);  

        }

        void datagrid1_RowdetailsVisibilityChanged(object sender, Microsoft.Windows.Controls.DataGridRowDetailsEventArgs e)
        {
            Microsoft.Windows.Controls.DataGrid innerDataGrid = e.DetailsElement as Microsoft.Windows.Controls.DataGrid;
            innerDataGrid.ItemsSource = ((IListSource)dt).GetList();
        }

在xaml文件中编写代码

代码语言:javascript
复制
        <my:DataGrid.RowDetailsTemplate>
            <DataTemplate>
                <my:DataGrid Name="datagrid2"></my:DataGrid>
            </DataTemplate>
        </my:DataGrid.RowDetailsTemplate>
    </my:DataGrid>
</Grid>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3192221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档