title: Setting Canvas.Left for ItemsControl's items
body: <p>I'm working on a Windows 8 app. I have to place several controls (images, rectangles) inside a Canvas. If I do it directly, everything is fine when I'm using "Canvas.Left" attached property on the children (the mentioned controls). However, I'd like to use MVVM. Therefore I now use an ItemsControl like this: </p>
  
  <pre><code>    &lt;ItemsControl ItemsSource="{Binding MyObjects}"&gt;
          &lt;ItemsControl.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;Canvas /&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ItemsControl.ItemsPanel&gt;
          &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel&gt;
                      &lt;Image Source="{Binding Image}" Visibility="{Binding IsImage, Converter={StaticResource boolConverter}}" /&gt;
                      &lt;Rectangle Canvas.Left="{Binding Left}" Canvas.Top="{Binding Top}" Width="{Binding Width}" Height="{Binding Height}" Fill="{Binding Fill}" Visibility="{Binding IsNoImage, Converter={StaticResource boolConverter}}" /&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
      &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>Binding is working except for the attached Canvas properties. After some research I found out that's because of ItemsControl wrapping its children with a ContentPresenter. Therefore I tried to make use a solution I found on stackoverflow, but without success:</p>
  
  <pre><code>&lt;ItemsControl.ItemContainerStyle&gt;
     &lt;Style TargetType="ContentPresenter"&gt;
         &lt;Setter Property="Canvas.Left" Value="{Binding Left}" /&gt;
     &lt;/Style&gt;
  &lt;/ItemsControl.ItemContainerStyle&gt;
  </code></pre>
  
  <p>Adding this code doesn't set the Canvas.Left property (even after removing the binding from the DataTemplate). </p>
  
  <p>What am I missing? Thanks in advance.</p>