在DataGrid中添加自定义工具提示行 [英] Add custom tooltip to row in DataGrid
本文介绍了在DataGrid中添加自定义工具提示行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想自定义我的DataGrid在所选行中显示一个工具提示,请参阅下面的模型图,以便更好地了解我想要实现的内容。
I would like to customize my DataGrid to show a tooltip within the selected row, please see the mockup images below for a better idea of what I want to achieve.
目前为止 - 显示一个选定的行:
As it is at the moment - Shows a single selected row:
我希望如何 - 显示同样的行,现在使用工具提示:
How I would like - Shows the same row selected, now with tooltip:
- 我的DataGrid使用对ViewModel的绑定。
- 使用WPF& C#for Windows桌面。
我真的不知道如何实现这一点,所以我可以接受任何建议全部。
I don't really have any idea how to achieve this, so I'm open to any suggestions at all.
推荐答案
您可以使用 RowDetailsTemplate 。
以下是示例代码:
<DataGrid Name="grid" AutoGenerateColumns="False">
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<TextBlock Background="Orange" Text="{Binding MoreInfo}" TextWrapping="Wrap"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</DataTemplate>
</DataGrid.RowDetailsTemplate>
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding ID}" />
<DataGridTextColumn Header="ID" Binding="{Binding Name}" />
<DataGridTextColumn Header="ID" Binding="{Binding Surname}" />
</DataGrid.Columns>
</DataGrid>
这篇关于在DataGrid中添加自定义工具提示行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文