I have a hard coded Path
shape inside of a Canvas
. I want to have multiple shapes inside this canvas so I\'m trying to shove the information of each s
The Canvas.Left
and Canvas.Top
bindings in your ItemTemplate
have no effect, because the Path control in the DataTemplate does not have a Canvas parent.
In order to make it work you would have to set the ItemsPanel
and ItemContainerStyle
properties like this:
<ItemsControl ItemsSource="{Binding CanvasPaths}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding CanvasLeft}"/>
<Setter Property="Canvas.Top" Value="{Binding CanvasTop}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Path Style="{StaticResource OverlayPath}"
Data="{Binding Data}"
Height="{Binding Height}"
Width="{Binding Width}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>