使用扩展器展开和折叠行详细信息。

问题描述:

我上传的示例项目在的 WpfApp1。在OneDrive上压缩

I uploaded a sample project at WpfApp1.zip on OneDrive.

关键点是点击该行以显示行详细信息。 

The key point is to click the row to show the row details. 

<Grid Margin="10">
        <DataGrid Name="dgUsers" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}" />
                <DataGridTextColumn Header="Birthday" Binding="{Binding Birthday}" />
            </DataGrid.Columns>
            <DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Details}" Margin="10" />
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>
        </DataGrid>
    </Grid>


但是我的任务有点不同。在DataGrid中,我们只显示摘要。当在文本块中显示细节时,它显示一个扩展器。单击它然后显示详细信息。再次单击它(折叠,它将隐藏整个细节(textblock )。
我无法做到这一点。

我不确定我是否按照你想要的方式行事。

I'm not sure I follow what you want to do.

你只想要在行尾的扩展器与里面的文本块?

You just want an expander in the rowdetails with the textblock inside it?

            <DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <Expander>
                        <TextBlock Text="{Binding Details}" Margin="10" />
                    </Expander>
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>