silverlight datagrid 中的嵌套列、嵌套数据网格

发布于 2024-12-05 03:42:59 字数 240 浏览 1 评论 0原文

我想创建具有嵌套列的数据网格(请查看附图)。或者如果可能的话将网格嵌入到单元格中。 我的对象有许多不同的信息,根据对象类型,我想在我的单元格(图像中的嵌套列)中添加附加信息,该信息按列划分。在银光下可以吗?

如果可能的话,将整个新网格插入到单元格中将是完美的。

TIA 提供任何建议

嵌套网格 silverlight

I would like to create datagrid that has nested columns (please look at attached image). Or if possible embed grid into cell.
My objects have many different informations, and based on object type I would like to add additional info in my cell (nested Column in the image), that is divided by columns. Is it possible in silverlight ?

It would be perfect to just insert the whole new grid into cell, if possible.

TIA for any suggestions

Nested grid silverlight

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

落花随流水 2024-12-12 03:42:59

抱歉,我读了“网格”8-)

对于数据网格,您可以使用数据模板来完成。

http://mscoder.wordpress。 com/2010/09/11/nested-datagrid-using-silverlight-4-and-wcf/

Sorry, I read "Grid" 8-)

For datagrid you'll be able to do it with datatemplates.

http://mscoder.wordpress.com/2010/09/11/nested-datagrid-using-silverlight-4-and-wcf/

·深蓝 2024-12-12 03:42:59

利用数据网格的 LoadingRow 事件根据您的数据上下文分配适当的数据模板。

类似于我的回复:

在数据网格中启用/禁用行

您执行以下操作:

private void MyDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
    MyDataObjectClass dataContext = (e.Row.DataContext as MyDataObjectClass);

    foreach (DataGridColumn col in from cols in MyDataGrid.Columns orderby cols.DisplayIndex select cols)
    {
        FrameworkElement fe = col.GetCellContent(e.Row);

        DataGridCell result = fe.Parent as DataGridCell;

        // as an example, find a template column w/ a desired sort member path
        if (col is DataGridTemplateColumn && col.SortMemberPath == "x")
        {
            if (condition1)
            {
                result.ContentTemplate = (DataTemplate)Resources["NestedGridTemplate1"];
            }
            else 
            {
                result.ContentTemplate = (DataTemplate)Resources["NestedGridTemplate2"];
            }                   
        }
    }
}

Leverage the LoadingRow event for your data grid to assign the appropriate datatemplate based on your datacontext.

Similar to my response to:

Enabling/Disabling row in a data grid

You do the following:

private void MyDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
    MyDataObjectClass dataContext = (e.Row.DataContext as MyDataObjectClass);

    foreach (DataGridColumn col in from cols in MyDataGrid.Columns orderby cols.DisplayIndex select cols)
    {
        FrameworkElement fe = col.GetCellContent(e.Row);

        DataGridCell result = fe.Parent as DataGridCell;

        // as an example, find a template column w/ a desired sort member path
        if (col is DataGridTemplateColumn && col.SortMemberPath == "x")
        {
            if (condition1)
            {
                result.ContentTemplate = (DataTemplate)Resources["NestedGridTemplate1"];
            }
            else 
            {
                result.ContentTemplate = (DataTemplate)Resources["NestedGridTemplate2"];
            }                   
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文