I want to display an image on hover of a DataGridTextColumn
with use of ToolTip
. It's working great so far but I need to disable the ToolTip if there is no image available.
This is my Code so far:
<DataGridTextColumn Header="{lex:Loc material}" Binding="{Binding Material}" Width="Auto" MinWidth="75" ToolTipService.IsEnabled="{Binding ProductImageExists}" ToolTipService.ShowDuration="99999" ToolTipService.InitialShowDelay="0">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Setter Property="ToolTip">
<Setter.Value>
<Image Source="{Binding ProductImage}" Width="250" />
</Setter.Value>
</Setter>
</Style>
</DataGridTextColumn.CellStyle>
Result of output
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=ProductImageExists; DataItem=null; target element is 'DataGridTextColumn' (HashCode=42700980); target property is 'IsEnabled' (type 'Boolean')
Why does the tooltip has another datacontext? How can I set it to the correct one?