title: How to change BorderBrush of the DataGrid's Border by value
body: <p>Hi I am trying to change BorderBrush property of the Border elemen in DataGrid depend on Value of the records.
  For example if  record will have value = &quot;Low&quot; the BorderBrush will change color to Green
  value = &quot;Medium&quot; the color will be yellow etc..
  How can I achieve this? I made CellConverter, but how to use him for Border?</p>
  <pre><code> &lt;Style x:Key=&quot;DataGridRowStyle2&quot; TargetType=&quot;{x:Type DataGridRow}&quot;&gt;
                  &lt;Setter Property=&quot;Background&quot; Value=&quot;Transparent&quot;/&gt;
                  &lt;Setter Property=&quot;SnapsToDevicePixels&quot; Value=&quot;true&quot;/&gt;
                  &lt;Setter Property=&quot;BorderBrush&quot; Value=&quot;Transparent&quot;/&gt;
                  &lt;Setter Property=&quot;ValidationErrorTemplate&quot;&gt;
                      &lt;Setter.Value&gt;
                          &lt;ControlTemplate&gt;
                              &lt;TextBlock Foreground=&quot;Transparent&quot; Margin=&quot;2,0,0,0&quot; Text=&quot;!&quot; VerticalAlignment=&quot;Center&quot;/&gt;
                              
                          &lt;/ControlTemplate&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
                  &lt;Setter Property=&quot;Template&quot;&gt;
                      &lt;Setter.Value&gt;
                          &lt;ControlTemplate TargetType=&quot;{x:Type DataGridRow}&quot;&gt;
                            //This one
                              &lt;Border x:Name=&quot;DGR_Border&quot;  CornerRadius=&quot;5&quot; Background=&quot;{TemplateBinding Background}&quot; BorderThickness=&quot;2&quot; BorderBrush=&quot;Red&quot; SnapsToDevicePixels=&quot;True&quot;&gt;
                                  &lt;SelectiveScrollingGrid&gt;
                                      
                                      &lt;SelectiveScrollingGrid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                          &lt;ColumnDefinition Width=&quot;*&quot;/&gt;
                                      &lt;/SelectiveScrollingGrid.ColumnDefinitions&gt;
                                      &lt;SelectiveScrollingGrid.RowDefinitions&gt;
                                          &lt;RowDefinition Height=&quot;*&quot;/&gt;
                                          &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                      &lt;/SelectiveScrollingGrid.RowDefinitions&gt;
                                      &lt;DataGridCellsPresenter ItemsPanel=&quot;{TemplateBinding ItemsPanel}&quot; SnapsToDevicePixels=&quot;{TemplateBinding SnapsToDevicePixels}&quot;/&gt;
                                      &lt;DataGridDetailsPresenter Visibility=&quot;{TemplateBinding DetailsVisibility}&quot;/&gt;
                                      &lt;DataGridRowHeader Visibility=&quot;{Binding HeadersVisibility, Converter={x:Static DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}&quot;/&gt;
                                  &lt;/SelectiveScrollingGrid&gt;
                                  
                              &lt;/Border&gt;
                              
                          &lt;/ControlTemplate&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
  </code></pre>
  <blockquote>
  <p>CellConvertor class</p>
  </blockquote>
  <pre><code> public class CellConverter : IValueConverter
      {
  
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              string input = value as string;
              switch (input)
              {
                  case &quot;High&quot;:
                  return Brushes.Red;
                     
                  case &quot;Medium&quot;:
                      return Brushes.Yellow;
                      
                  case &quot;Low&quot;:
                      return Brushes.Green;
                  default:
                      return DependencyProperty.UnsetValue;
              }
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
          {
              throw new NotImplementedException();
          }
      }
  </code></pre>