title: Changing background color for WPF DataGrid cell depending on selection and value
body: <p>I'm trying to achieve this: <strong>When the user selects one or multiple cells in a DataGrid all duplicates should have their background color changed</strong>.</p>
  
  <p>I have this xaml</p>
  
  <pre><code>&lt;Window x:Class="NotesOnFretboard.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;DataGrid ItemsSource="{Binding}" AutoGenerateColumns="true"  Margin="12,110,12,29" Name="dataGrid1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsReadOnly="True" /&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>code behind:</p>
  
  <pre><code>public MainWindow()
  {
      InitializeComponent();
      DataTable dt = CreateDataTable();
  
      dataGrid1.ItemsSource = dt.DefaultView;
  }
  </code></pre>
  
  <p>So I populate the datagrid using a DataTable(10 rows, 25 columns).
  In this datatable there are a number of duplicate values.</p>
  
  <p>When the user selects one or multiple cells in a DataGrid all duplicates should have their background color changed!</p>
  
  <p>Please Help!</p>
  
  <p>// Anders</p>