title: UWP Binding in Style Setter from ItemContainerStyle not working
body: <p>I create a BindingHelper to set a binding in a style setter like this example....</p>
  
  <p><a href="https://stackoverflow.com/questions/33573929/uwp-binding-in-style-setter-not-working">UWP Binding in Style Setter not working</a></p>
  
  <p>But it dont works.
  Can anyon help me to complete the example or find my error?</p>
  
  <pre><code>&lt;Page
  x:Class="eve.TerminView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:eve"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"&gt;
  
  &lt;Page.Resources&gt;
      &lt;ResourceDictionary Source="Styles.xaml" /&gt;
  
  &lt;/Page.Resources&gt;
  
  &lt;Grid Background="{StaticResource ResourceKey=StyleBackground}"&gt;
  
      &lt;ItemsControl ItemsSource="{Binding Path=termindata}"&gt;
          &lt;ItemsControl.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
  
                  &lt;Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="50" BorderBrush="White" BorderThickness="1"&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                          &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                          &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                  &lt;/Grid&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ItemsControl.ItemsPanel&gt;
          &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;Border Background="Green"&gt;
                      &lt;TextBlock Text="{Binding text}"&gt;&lt;/TextBlock&gt;
                  &lt;/Border&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
  
          &lt;ItemsControl.ItemContainerStyle&gt;
              &lt;Style TargetType="ContentPresenter"&gt;
                  &lt;Setter Property="local:BindingHelper.GridColumnBindingPath" Value="column"/&gt;
                  &lt;Setter Property="local:BindingHelper.GridRowBindingPath" Value="row"/&gt;
              &lt;/Style&gt;
          &lt;/ItemsControl.ItemContainerStyle&gt;
  
      &lt;/ItemsControl&gt;
  
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here the code behind with the public class BindingHelper</p>
  
  <pre><code>namespace test
  {
  
  public sealed partial class TerminView : Page
  {
  
      public List&lt;TerminDate&gt; termindata;
  
  
      public TerminView()
      {
          this.InitializeComponent();
  
          termindata = new List&lt;TerminDate&gt;();
  
          termindata.Add(new TerminDate(1, 1, "Test 1"));
          termindata.Add(new TerminDate(1, 2, "Test 2"));
      }
  }
  
  
  public class TerminDate
  {
  
      public TerminDate(int row, int column, string text)
      {
          this.row = row;
          this.column = column;
          this.text = text;
      }
  
      public int row { get; set; }
      public int column { get; set; }
      public string text { get; set; }
  }
  
  public class BindingHelper
  {
      public static readonly DependencyProperty GridColumnBindingPathProperty =
          DependencyProperty.RegisterAttached(
              "GridColumnBindingPath", typeof(string), typeof(BindingHelper),
              new PropertyMetadata(null, GridBindingPathPropertyChanged));
  
      public static readonly DependencyProperty GridRowBindingPathProperty =
          DependencyProperty.RegisterAttached(
              "GridRowBindingPath", typeof(string), typeof(BindingHelper),
              new PropertyMetadata(null, GridBindingPathPropertyChanged));
  
      public static string GetGridColumnBindingPath(DependencyObject obj)
      {
          return (string)obj.GetValue(GridColumnBindingPathProperty);
      }
  
      public static void SetGridColumnBindingPath(DependencyObject obj, string value)
      {
          obj.SetValue(GridColumnBindingPathProperty, value);
      }
  
      public static string GetGridRowBindingPath(DependencyObject obj)
      {
          return (string)obj.GetValue(GridRowBindingPathProperty);
      }
  
      public static void SetGridRowBindingPath(DependencyObject obj, string value)
      {
          obj.SetValue(GridRowBindingPathProperty, value);
      }
  
      private static void GridBindingPathPropertyChanged(
          DependencyObject obj, DependencyPropertyChangedEventArgs e)
      {
          var propertyPath = e.NewValue as string;
  
          if (propertyPath != null)
          {
              var gridProperty =
                  e.Property == GridColumnBindingPathProperty
                  ? Grid.ColumnProperty
                  : Grid.RowProperty;
  
              BindingOperations.SetBinding(
                  obj,
                  gridProperty,
                  new Binding { Path = new PropertyPath(propertyPath) });
          }
      }
  }
  
  }
  </code></pre>