How to display CellValue in Comments Tooltip?
In GridDataControl, you can enable or disable the Comments Tooltip by using GridCommentService.ShowComment attached property. You can define DataTemplate for comments Tooltip using CommentTemplatekey property in GridDataColumnStyle and the DataContext for DataTemplate is the GridStyleInfo of a particular cell.
In the following code example, CommentTemplatekey is defined inside the GridDataColumnStyle.
XAML
<Window x:Class="GridDataControlSample.MainWindow" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" > <Window.Resources> <DataTemplate x:Key="commenttext" > <StackPanel Background="Red"> <TextBlock x:Name="txtblck" Text="{Binding Path=CellValue}"/> </StackPanel> </DataTemplate> </Window.Resources> <syncfusion:GridDataControl Name="syncgrid" syncfusion:GridCommentService.ShowComment="True" ItemsSource="{Binding GDCSource}" Grid.Row="2" Grid.Column="0" UpdateMode="PropertyChanged" ListBoxSelectionMode="None" NotifyPropertyChanges="True" > <syncfusion:GridDataControl.VisibleColumns> <syncfusion:GridDataVisibleColumn MappingName="CustomerName" > <syncfusion:GridDataVisibleColumn.ColumnStyle> <syncfusion:GridDataColumnStyle CommentTemplateKey="commenttext" Comment="test" > </syncfusion:GridDataColumnStyle> </syncfusion:GridDataVisibleColumn.ColumnStyle> </syncfusion:GridDataVisibleColumn> </syncfusion:GridDataControl.VisibleColumns> </syncfusion:GridDataControl> </Window>
The following screenshot displays the cell value as comment tooltip when you hover the mouse on it.
Figure 1: Cell value displayed as comment tooltip
You can also set the Tooltip based on cell using GridDataControl.Mode.QueryCellInfo event.
C#
public MainWindow() { InitializeComponent(); this.syncgrid.Model.QueryCellInfo += Model_QueryCellInfo; } void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { if (e.Style.RowIndex > 0) { var style = e.Style as GridDataStyleInfo; string columnName = style.CellIdentity.Column.MappingName; if (columnName == "CustomerName") { e.Style.CommentTemplateKey = "commenttext"; e.Style.Comment = "Test"; } } }
You can refer to the following sample links to display the cellvalue of comments tooltip for WPF platforms.
Sample Link: CommentsToolTip_WPF