Hello,
I need to display in my XamDataGrid a tooltip on one column only. This tooltip will be bound to a property in my ViewModel. Plus, I need the tooltip to be shown only if this property (string) is not null or empty.
I could display the tooltip on my first columns, following suggestions provided here: https://ko.infragistics.com/community/forums/t/71444.aspx
However, I cannot find a way to hide the tooltip if the property is null or empty string.
What I do NOT want is to have an empty tooltip box: I just don;t want the tooltip to appear.
here is my code: The textField column has a tooltip bound to the Description property. I understood that maybe a way to do this is using datatriggers, but I could not find a way to apply the trigger to the tooltip property only (and no to the entire style.. infact the trigger part in my code is commented, since it would hide the whole content of my cell)
<igWPF:TextField Name="AttributeName" Label="{local:Localizer ProfileManager_AttributeName}" Width="*"> <!--Set Tooltip for this cell only--> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="ToolTip"> <Setter.Value> <TextBlock Text="{Binding DataItem.Description}"/> </Setter.Value> </Setter> <!--<Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=DataItem.Description}" Value="{x:Null}"> <Setter Property="Visibility" Value="Collapsed" /> </DataTrigger> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=DataItem.Description}" Value=""> <Setter Property="Visibility" Value="Collapsed" /> </DataTrigger> </Style.Triggers>--> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igWPF:TextField>
Please, help me to find a solution!
Thanks in advance
best regards
Valentina
Hello Valentina,
Thank you for your feedback.
I am glad to know that I was able to help you achieve the functionality you were looking for.
I believe this thread can help other people looking for a similar solution.
If you have any questions, please let me know.
Hello Tacho,
thanks for your feedback and help, it works like a charm!
I realized that I made a stupid mistake (setting "Visibility" instead of "Tooltip" property in my DataTrigger)
Thanks again
Thank you for the detailed description and the code-snippet you have provided.
In order not to visualize the ToolTip whenever the Description of the DataItem is null or empty, you can simply set the ToolTip property of the CellValuePresenter to null.
<!-- ========== Set ToolTip to a TextBlock. ========== -->
<Setter Property="ToolTip"> <Setter.Value> <TextBlock Text="{Binding DataItem.Description}" /> </Setter.Value></Setter>
<!-- ========== Set ToolTip to null whenever Description is null or empty. ========== -->
<Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.Description}" Value="{x:Null}"> <Setter Property="ToolTip" Value="{x:Null}" /> </DataTrigger> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.Description}" Value=""> <Setter Property="ToolTip" Value="{x:Null}" /> </DataTrigger></Style.Triggers>
I have attached a sample application that demonstrates the approach from above.