[英]How do I Add a Tooltip To a DataGridTextColumn
I'm using WPFtoolkit DataGrid
,I have to wrap text in a DataGridTextColumn
or I have to add a ToolTip
to the text column. 我正在使用WPFtoolkit DataGrid
,我必须在DataGridTextColumn
包装文本,或者我必须在文本列中添加ToolTip
。 I have searched the net but i couldn't get a proper solution. 我在网上搜索过,但我找不到合适的解决方案。 Expecting your valuable suggestions... 期待您的宝贵建议......
Yes, you can add tooltip text to DataGridTextColumn - just stylize it 是的,您可以将工具提示文本添加到DataGridTextColumn - 只需将其样式化即可
<DataGridTextColumn Header="ScreenName" Binding="{Binding ScreenName}" >
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ToolTip" Value="{Binding Name}" />
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
I'm not sure if you can add a tooltip to a DataGridTextColumn
but you can easily use the DataGridTemplateColumn
and the ToolTipService
instead. 我不确定您是否可以向DataGridTextColumn
添加工具提示,但您可以轻松地使用DataGridTemplateColumn
和ToolTipService
。 eg 例如
<data:DataGrid.Columns>
<data:DataGridTemplateColumn Header="Broker">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Moniker.Abbreviation}"
ToolTipService.ToolTip="{Binding Moniker.Name}" />
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
In this example Moniker.Abbreviation
is displayed in the column. 在此示例中, Moniker.Abbreviation
显示在列中。 When the user hovers over a cell, the full broker name ( Moniker.Name
) is displayed in the tooltip. 当用户将鼠标悬停在单元格上时,工具提示中会显示完整的代理名称( Moniker.Name
)。
Note: This example was taken from a Silverlight 3.0 application. 注意:此示例取自Silverlight 3.0应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.