We recommend that you use the xamDataGrid control instead of the xamGrid control. The xamGrid is being planned for retirement over the next few years and will not receive any new features. We will continue to provide support and critical bug fixes for the xamGrid during this time. 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>