3
A
回答
1
在DataGrid,添加以下内容:
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding students}">
</DataGrid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
0
如果你想内嵌显示在表中的细节,@AnsonWoody写的答案。如果要在单独的控件中显示外部详细信息,请使用CollectionViewSource
的DateGrid
或CurrentItem
的SelectedItem
。
假设你的datacontext中包含的项目在ClassesWithStudents
和每个项目都有一个属性Students
,你可以做到以下几点:
<StackPanel x:Name="panel1">
<StackPanel.Resources>
<CollectionViewSource x:Key="classesCollection" Source="{Binding ClassesWithStudents}"/>
</StackPanel.Resources>
<DataGrid x:Name="dg1" ItemsSource="{Binding Source={StaticResource classesCollection}}">
</DataGrid>
<!-- Bind current item with path=/ -->
<ContentControl Content="{Binding Source={StaticResource classesCollection},Path=/Students}"/>
<!-- Bind selected item -->
<ContentControl Content="{Binding ElementName=dg1,Path=SelectedItem.Students}"/>
</StackPanel>
Ofcourse的ContentControl
只是一个占位符。如果Students
是一个集合,请使用诸如<ItemsControl ItemsSource="{Binding Source={StaticResource classesCollection},Path=/Students}"/>
之类的东西或任何适合您需要的内容,以获得漂亮的学生表示。
相关问题
- 1. 通过单击行标题显示DataGrid行详细信息?
- 2. 显示行详细信息
- 3. 显示单击行的引导程序表的详细信息
- 4. 防止单击超链接时显示详细信息
- 5. 如何在datagrid行详细信息中显示部分文本?
- 6. 获取DataGrid行详细信息
- 7. 动画WPF DataGrid行详细信息
- 8. PHP MYSQL Table Row单击以显示数据的详细信息
- 9. 单击图像的详细信息页
- 10. Android主详细信息详细信息
- 11. Crystal Reports详细信息详细信息
- 12. WPF工具包Datagrid - 显示详细行
- 13. Silverlight的DataGrid,显示多个行的详细信息,但不是所有的行
- 14. 显示来自ListView的详细信息
- 15. 图片//详细信息不显示
- 16. 显示TXT文件的详细信息
- 17. Exchange模拟不显示详细信息
- 18. 显示/隐藏详细信息WinForm
- 19. PhpStorm - 显示详细的doctag信息
- 20. 显示进口商的详细信息
- 21. 显示详细的错误信息
- 22. ASP.NET显示错误详细信息
- 23. 单击“更多详细信息”后,以GMT显示的事件时间
- 24. Sitecore演示详细信息
- 25. 单击单选按钮时过滤用户详细信息?
- 26. Android:droidar设置POI并点击显示详细信息
- 27. 点击地图上的angular2开放层显示详细信息
- 28. Woocommerce - 在订单详细信息中显示订单总数
- 29. 如何更改每个DataGrid行详细信息的行详细信息的DataTemplate中的TextBlock文本?
- 30. 运行时C函数详细信息
您可以在https://www.wpftutorial.net/DataGrid.html的“行详细信息”部分下找到有关该主题的基本信息, – hypnos 2016-12-12 07:35:52