title: WPF - XAML - DataGridRow Style Trigger IsMouseOver tooltip data binding
body: <p>I am trying to get a tool tip to show an image upon a mouse hover of a row inside of a DataGrid in WPF.</p>
  
  <p>Here is a snippet of the XAML for the RowStyle:</p>
  
  <pre><code>            &lt;DataGrid.RowStyle&gt;
              &lt;Style TargetType="DataGridRow" &gt;
                  &lt;Style.Triggers&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="False"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.OfflineColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="True"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.OnlineColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="{x:Null}"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.UnknownColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                      &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                          &lt;Setter Property="DataContext" Value="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}"/&gt;
                          &lt;Setter Property="ToolTip"&gt;
                              &lt;Setter.Value&gt;
                                  &lt;Image Height="50" Width="50" Source="{Binding userimg}"/&gt;
                              &lt;/Setter.Value&gt;
                          &lt;/Setter&gt;
                      &lt;/Trigger&gt;
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/DataGrid.RowStyle&gt;
  </code></pre>
  
  <p>I know <strong>userimg</strong> is set correctly because if I take this line:</p>
  
  <pre><code>&lt;Image Height="50" Width="50" Source="{Binding userimg}"/&gt;
  </code></pre>
  
  <p>And put it somewhere else in my XAML I see the image.  If I change the userimg (it's just a string to a path of a PNG) to a hard coded path it seems to work, so I know it is a datacontext issue.</p>
  
  <p>I have tried several things including: <a href="https://stackoverflow.com/questions/16173869/wpf-error-40-bindingexpression-path-error-property-not-found-on-object">this</a>, <a href="https://wpf.2000things.com/2011/08/30/375-binding-something-in-a-tooltip-to-a-property-on-the-parent-control/" rel="nofollow noreferrer">this</a>, <a href="https://stackoverflow.com/questions/14161504/datacontext-of-datatemplate-in-tooltip-style-in-wpf">this</a>, and <a href="https://stackoverflow.com/questions/14510931/is-there-a-way-to-determine-where-a-wpf-binding-is-declared-created/14523290#14523290">this</a> but I am still struggling to get this image to show by using data binding.</p>
  
  <p>I have also tried this with no luck either:</p>
  
  <pre><code>&lt;Setter Property="ToolTip"&gt;
  &lt;Setter.Value&gt;
      &lt;Image Height="50" Width="50" Source={Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.userimg,UpdateSourceTrigger=PropertyChanged}"/&gt;
  &lt;/Setter.Value&gt;
  </code></pre>
  
  <p>   </p>
  
  <p>These are the errors that show up when I try to view the tooltip:</p>
  
  <pre><code>System.Windows.Data Error: 40 : BindingExpression path error: 'userimg' property not found on 'object' ''DataRowView' (HashCode=6587426)'. BindingExpression:Path=userimg; DataItem='DataRowView' (HashCode=6587426); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  
  System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=userimg; DataItem='DataRowView' (HashCode=6587426); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  
  System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=userimg; DataItem='DataRowView' (HashCode=6587426); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  
  System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=userimg; DataItem='DataRowView' (HashCode=6587426); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  
  System.Windows.Data Information: 41 : BindingExpression path error: 'userimg' property not found for 'object' because data item is null.  This could happen because the data provider has not produced any data yet. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  
  System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  
  System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  
  System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  </code></pre>
  
  <p>Can someone please help, can't afford to loose anymore hair...</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thanks for the reply Andy, Here is my entire snippet of the datagrid:</p>
  
  <pre><code>        &lt;DataGrid Grid.Row="1" Grid.ColumnSpan="187"  Name="DG1" Background="Transparent" Foreground="{Binding MyForegroundColor}" BorderThickness="0" HeadersVisibility="Column" CanUserAddRows="False" IsReadOnly="True" Opacity="1" SelectionMode="Single" AutoGenerateColumns="True"&gt;
          &lt;DataGrid.Resources&gt;
              &lt;Style TargetType="ScrollBar"&gt;
                  &lt;Setter Property="Opacity" Value=".3" /&gt;
              &lt;/Style&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{Binding MyAccentColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="{Binding MyForegroundColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"  Color="{Binding MyAccentColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="{Binding MyForegroundColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;Image x:Key="yuserimg" Height="50" Width="50" Source="{Binding userimg}"/&gt;
          &lt;/DataGrid.Resources&gt;
          &lt;DataGrid.ColumnHeaderStyle&gt;
              &lt;Style TargetType="{x:Type DataGridColumnHeader}"&gt;
                  &lt;Setter Property="HorizontalContentAlignment" Value="Left" /&gt;
                  &lt;Setter Property="FontWeight" Value="bold"/&gt;
                  &lt;Setter Property="Margin" Value="0"/&gt;
                  &lt;Setter Property="Padding" Value="1" /&gt;
                  &lt;Setter Property="Background" Value="Transparent" /&gt;
                  &lt;Setter Property="BorderThickness" Value="1"/&gt;
              &lt;/Style&gt;
          &lt;/DataGrid.ColumnHeaderStyle&gt;
          &lt;DataGrid.RowStyle&gt;
              &lt;Style TargetType="DataGridRow" &gt;
                  &lt;Setter Property="ToolTip" Value="{Binding yuserimg}"/&gt;
                  &lt;Style.Triggers&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="False"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.OfflineColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="True"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.OnlineColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="{x:Null}"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.UnknownColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/DataGrid.RowStyle&gt;
      &lt;/DataGrid&gt;
  </code></pre>
  
  <p>However, when I hover over a row I don't see any tool tip pop up at all now.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>I updated the binding to dynamicresource as such:</p>
  
  <pre><code>            &lt;DataGrid.Resources&gt;
              &lt;Style TargetType="ScrollBar"&gt;
                  &lt;Setter Property="Opacity" Value=".3" /&gt;
              &lt;/Style&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{Binding MyAccentColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="{Binding MyForegroundColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"  Color="{Binding MyAccentColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="{Binding MyForegroundColor,Converter={StaticResource ColorToSolidColorBrush_ValueConverter}}"/&gt;
              &lt;Image x:Key="yuserimg" Height="50" Width="50" Source="{Binding userimg}"/&gt;
          &lt;/DataGrid.Resources&gt;
  
  
              &lt;DataGrid.RowStyle&gt;
              &lt;Style TargetType="DataGridRow" &gt;
                  &lt;Setter Property="ToolTip" Value="{DynamicResource yuserimg}"/&gt;
                  &lt;Style.Triggers&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="False"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.OfflineColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="True"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.OnlineColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                      &lt;DataTrigger Binding="{Binding Path=CNIsOnline,UpdateSourceTrigger=PropertyChanged}" Value="{x:Null}"&gt;
                          &lt;Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=DataContext.UnknownColor,UpdateSourceTrigger=PropertyChanged}"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/DataGrid.RowStyle&gt;
  </code></pre>
  
  <p>However, I still get binding errors and I just see a 50x50 box as the tooltip.</p>
  
  <p>Here are the binding errors:</p>
  
  <pre><code>System.Windows.Data Information: 41 : BindingExpression path error: 'userimg' property not found for 'object' because data item is null.  This could happen because the data provider has not produced any data yet. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=userimg; DataItem=null; target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
  </code></pre>