Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use a <code>MultiBinding</code>, with a first binding taking the actual data context from the cell (that would be the row), and the second one taking the column. From there, you can retrieve the cell value.</p> <p>Converter code:</p> <pre><code>public class RowColumnToCellConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { DataRowView row = values[0] as DataRowView; DataGridColumn column = values[1] as DataGridColumn; return row != null &amp;&amp; column != null ? row[column.SortMemberPath] : DependencyProperty.UnsetValue; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotSupportedException(); } } </code></pre> <p>XAML:</p> <pre><code> &lt;Style x:Key="{x:Type DataGridCell}" TargetType="{x:Type DataGridCell}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate&gt; &lt;StackPanel&gt; &lt;TextBlock x:Name="TextOK" Text="OK" Visibility="Collapsed" /&gt; &lt;/StackPanel&gt; &lt;ControlTemplate.Triggers&gt; &lt;DataTrigger Value="True"&gt; &lt;DataTrigger.Binding&gt; &lt;MultiBinding Converter="{StaticResource RowColumnToCellConverter}"&gt; &lt;Binding /&gt; &lt;Binding RelativeSource="{x:Static RelativeSource.Self}" Path="Column" /&gt; &lt;/MultiBinding&gt; &lt;/DataTrigger.Binding&gt; &lt;Setter TargetName="TextOK" Property="Visibility" Value="Visible" /&gt; &lt;/DataTrigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>I used a <code>TextBlock</code> instead an image for testing, but the code will be the same. Just avoid defining a style for the image if that can be done directly in the <code>DataGridCell</code>'s style.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload