ToolTips
Please note that this control has been retired and is now obsolete to the XamDataGrid control, and as such, we recommend migrating to that control. It will not be receiving any new features, bug fixes, or support going forward. For help or questions on migrating your codebase to the XamDataGrid, please contact support.
You can enable ToolTips on certain Columns so that when the end user hovers the mouse over a cell, that particular cell’s information is displayed. You can prevent ToolTips from appearing anywhere on the xamGrid control, customize them to appear only when the cell content overflows, or display them in all cases.
By default ToolTips do not appear.
You can enable ToolTips by setting the Column’s AllowToolTips property to one of the following values of the AllowToolTips enumeration:
-
Always: Display the ToolTips whenever the end user hovers over the cell.
-
Never: Never display the ToolTips.
-
Overflow: Only display the ToolTips when the cell content overflows.
<ig:XamGrid x:Name="MyDataGrid" ItemsSource="{Binding Source={StaticResource DataUtil}, Path=Products}" AutoGenerateColumns="False">
<ig:XamGrid.Columns>
<ig:TextColumn AllowToolTips="Always" Key="ProductID"/>
<ig:TextColumn AllowToolTips="Overflow" Key="ProductName"/>
<ig:TextColumn AllowToolTips="Never" Key="QuantityPerUnit"/>
<ig:TextColumn Key="UnitPrice"/>
</ig:XamGrid.Columns>
</ig:XamGrid>
MyDataGrid.Columns.DataColumns("ProductID").AllowToolTips = AllowTooltips.Always
MyDataGrid.Columns.DataColumns("ProductName").AllowToolTips = AllowTooltips.Overflow
MyDataGrid.Columns.DataColumns("QuantityPerUnit").AllowToolTips = AllowTooltips.Never
MyDataGrid.Columns.DataColumns["ProductID"].AllowToolTips = AllowTooltips.Always;
MyDataGrid.Columns.DataColumns["ProductName"].AllowToolTips = AllowTooltips.Overflow;
MyDataGrid.Columns.DataColumns["QuantityPerUnit"].AllowToolTips = AllowTooltips.Never;
You can style the ToolTip by setting the ToolTipStyle property that targets the ToolTip control.
You can specify the content of the ToolTip by setting the ToolTipContentTemplate property to an instance of a data template. The DataContext of this property is the Row’s data.
The following code demonstrates how set these properties to customize the ToolTip.
<ig:XamGrid x:Name="MyDataGrid" ItemsSource="{Binding Source={StaticResource
DataUtil}, Path=Products}" AutoGenerateColumns="False">
<ig:XamGrid.Columns>
<ig:TextColumn AllowToolTips="Always" Key="ProductID">
<!-- Set the ToolTipStyle property -->
<ig:TextColumn.ToolTipStyle>
<Style TargetType="ToolTip">
<Setter Property="Foreground" Value="Red"/>
</Style>
</ig:TextColumn.ToolTipStyle>
</ig:TextColumn>
<ig:TextColumn AllowToolTips="Overflow" Key="ProductName">
<!-- Set the ToolTipContentTemplate property -->
<ig:TextColumn.ToolTipContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding ProductID}"/>
</DataTemplate>
</ig:TextColumn.ToolTipContentTemplate>
</ig:TextColumn>
<ig:TextColumn AllowToolTips="Never" Key="QuantityPerUnit"/>
<ig:TextColumn Key="UnitPrice"/>
</ig:XamGrid.Columns>
</ig:XamGrid>