How to show tooltip on the disabled cell in WPF TreeGrid (SfTreeGrid)?
WPF TreeGrid (SfTreeGrid) allows you to show the ToolTip through the OnMouseEnter event. But the tooltip will not be displayed for disabled cells in TreeGrid. You can show tooltip for the disabled TreeGridCell and TreeGridExpandercell in TreeGrid by writing style and enabling ToolTipService.ShowOnDisabled.
<Window.Resources> <local:ToolTipConverter x:Key="converter"/> <Style x:Key="toolTipTreeGridExpanderCell" TargetType="syncfusion:TreeGridExpanderCell" > <Setter Property="ToolTip" Value="{Binding Converter={StaticResource converter}, RelativeSource={RelativeSource Mode=Self} }"/> <Setter Property="ToolTipService.IsEnabled" Value="True" /> <Setter Property="ToolTipService.ShowOnDisabled" Value="True" /> </Style> <Style x:Key="toolTipTreeGridCell" TargetType="syncfusion:TreeGridCell" > <Setter Property="ToolTip" Value="{Binding Converter={StaticResource converter}, RelativeSource={RelativeSource Mode=Self} }"/> <Setter Property="ToolTipService.IsEnabled" Value="True" /> <Setter Property="ToolTipService.ShowOnDisabled" Value="True" /> </Style> </Window.Resources> <Grid> <syncfusion:SfTreeGrid Name="treeGrid" AutoGenerateColumns="True" IsEnabled="False" ShowToolTip="True" ExpanderCellStyle="{StaticResource toolTipTreeGridExpanderCell}" CellStyle="{StaticResource toolTipTreeGridCell}" ChildPropertyName="ReportsTo" ParentPropertyName="ID" SelfRelationRootValue="-1" ItemsSource="{Binding Employees}" /> </Grid>
Here, TreeGridCell and TreeGridExpanderCell ToolTip are displayed using the converter, where the converter returns the cell value based on the underlying property.
public class ToolTipConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var treeGridcell = value as TreeGridCell; string cellvalue = string.Empty; var column = treeGridcell.ColumnBase.TreeGridColumn; var treeGrid = column.GetType().GetProperty("TreeGrid", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(column) as SfTreeGrid; if (treeGridcell != null && treeGridcell.ColumnBase != null && !treeGridcell.ColumnBase.IsEditing) { string formattedValue = ""; object value1 = null; if (treeGridcell.ColumnBase.ColumnElement != null) { value1 = treeGridcell.ColumnBase.ColumnElement.DataContext; } if (treeGridcell.ColumnBase.TreeGridColumn != null && treeGrid != null && treeGrid.View != null && treeGridcell.ColumnBase.TreeGridColumn.MappingName != null) { var tempFormatValue = treeGrid.View.GetPropertyAccessProvider().GetFormattedValue(value1, treeGridcell.ColumnBase.TreeGridColumn.MappingName); formattedValue = tempFormatValue == null ? null : tempFormatValue.ToString(); cellvalue = formattedValue; } } return cellvalue; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
The following screenshot shows the tooltip display for the disabled cell in TreeGrid,Take a moment to peruse the WPF TreeGrid – ToolTip documentation, where you can find about tooltip with code examples.
Conclusion
I hope you enjoyed learning about how to show tooltip on the disabled cell in WPF TreeGrid (SfTreeGrid).
You can refer to our WPF TreeGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!