C# 另一个数据网格中的数据网格

C# 另一个数据网格中的数据网格,c#,silverlight,datagrid,C#,Silverlight,Datagrid,我需要在另一个数据网格中显示一个数据网格。我通过使用RowDetailsTemplate并在其中添加一个datagrid来实现这一点。但主要的问题是,我需要同时显示多个内部网格。更改选定项目时,不会显示上一个选定项目的内部数据网格。任何建议: 我正在使用expander控件显示/隐藏详细信息。当expander控件打开时,我将RowDetailstemplate的visiblity更改为true 更改所选项目时,当前所选行的RowDetailsTemplate仅在我展开扩展程序时可见。您可以使用

我需要在另一个数据网格中显示一个数据网格。我通过使用RowDetailsTemplate并在其中添加一个datagrid来实现这一点。但主要的问题是,我需要同时显示多个内部网格。更改选定项目时,不会显示上一个选定项目的内部数据网格。任何建议:

我正在使用expander控件显示/隐藏详细信息。当expander控件打开时,我将RowDetailstemplate的visiblity更改为true


更改所选项目时,当前所选行的RowDetailsTemplate仅在我展开扩展程序时可见。

您可以使用属性控制每行行详细信息的可见性

当Selected找到答案时,您可能还需要更改为Visible以外的其他值

   private void Expander_Expanded(object sender, RoutedEventArgs e)
    {
    int rowIndex = this.DataGridForEvents.SelectedIndex;
    List<DataGridRow> rows = GetRows();
    rows[rowIndex].DetailsVisibility = Visibility.Visible;
    }

private void Expander_Collapsed(object sender, RoutedEventArgs e)
{
int rowIndex = this.DataGridForEvents.SelectedIndex;
List<DataGridRow> rows = GetRows();
rows[rowIndex].DetailsVisibility = Visibility.Collapsed;
}



public List<DataGridRow>  GetRows()
{
List<DataGridRow> rows = new List<DataGridRow>();
foreach (var rowItem in this.DataGridForEvents.ItemsSource)
{
this.DataGridForEvents.ScrollIntoView(rowItem, this.DataGridForEvents.Columns.Last());
FrameworkElement el = this.DataGridForEvents.Columns.Last().GetCellContent(rowItem);
DataGridRow row = DataGridRow.GetRowContainingElement(el.Parent as FrameworkElement);
if (row != null)
rows.Add(row);
}
return rows;
}