Hi,
I am using the ToolTipContentTemplate to show the tooltip on one of the XAMGRID template column.The XAML snippet for the same is shown below:
<Ig:TemplateColumn.ToolTipContentTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding SomeField}" />
</StackPanel>
</DataTemplate>
</Ig:TemplateColumn.ToolTipContentTemplate>
This template column has a ItemTemplate (TextBlock) and a EditorTemplate (Control derived from TextBox).
With the above code the tooltip appears as expected but one of my requirement is to conditionally remove the tooltip for the cells at runtime. The tooltip should not be visible even if it is in edit mode.
I would appreciate, if you could please provide some guidance for the implementation of the above requirement.
Thanks,
Samson Tuscano
Hello Samson,
Thank you for the code-snippet and the description you have provided.
In order to disable the cells' ToolTips of a Column based on a condition, the easiest way would be by setting the AllowToolTips property of the respective Column to Never when the certain condition is met/not met.
This way by explicitly performing the condition check, you will be able to either enable or disable the tooltips.
I have attached a sample application, where the CellExitedEditMode event of the XamGrid has been handled and whenever a cell from the Weight column becomes greater than a certain value, the tooltips of the column will get disabled.
private void xamGrid_CellExitedEditMode(object sender, CellExitedEditingEventArgs e){ var weightColumn = (sender as XamGrid).Columns["Weight"] as Column; if (e.Cell.Column == weightColumn && IsAnyWeightCellValueGreaterThan(20.0)) { weightColumn.AllowToolTips = AllowToolTips.Never; } else { weightColumn.AllowToolTips = AllowToolTips.Always; }}
if (e.Cell.Column == weightColumn && IsAnyWeightCellValueGreaterThan(20.0)) { weightColumn.AllowToolTips = AllowToolTips.Never; } else { weightColumn.AllowToolTips = AllowToolTips.Always; }}
If you have any further questions, please let me know.
Hi Tacho,
Thank you for your help.
I've checked your sample application, and i have noticed that it disables the Tooltip for the entire column(all cells in that column).
But, my requirement is to disable the Tooltip for a specific cell in a column.
Please suggest.
Thanks and regards,
Hello Samson,In order to enable/disable the tooltip of a specific cell, an approach I can suggest you is to set the tooltip of every CellControl (visual representation of the Cell) inside the CellControlAttached event of the XamGrid.This way we will be able to manually manipulate the tooltip for every cell without using the built-in functionality of the XamGrid (which will automatically set the tooltip, regardless of our manipulation).
private void xamGrid_CellControlAttached(object sender, CellControlAttachedEventArgs e){ var weightColumn = (sender as XamGrid).Columns["Weight"] as Column; if (e.Cell.Column == weightColumn) { double cellVal = 0.0; double.TryParse(e.Cell.Value.ToString(), out cellVal); if (cellVal > 20.0) ToolTipService.SetToolTip(e.Cell.Control as CellControl, null); else ToolTipService.SetToolTip(e.Cell.Control as CellControl, cellVal); }}
if (e.Cell.Column == weightColumn) { double cellVal = 0.0; double.TryParse(e.Cell.Value.ToString(), out cellVal);
if (cellVal > 20.0) ToolTipService.SetToolTip(e.Cell.Control as CellControl, null); else ToolTipService.SetToolTip(e.Cell.Control as CellControl, cellVal); }}
I have modified the sample from my previous reply with the approach from above.If you have any further questions, please let me know.