Binding de RelayCommand sur Polygon dans un IntemsControl
Bonjour à tous,
Je souhaite pouvoir lier une propriété de type RelayCommand aux Polygon générés par mon ItemsControl, ce que je ne parviens pas à faire.:aie:
Voici le xaml:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<ItemsControl DataContext="{Binding Source={StaticResource LocatorVM}, Path=Wm1 }" ItemsSource="{Binding ListPolygon}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Polygon Points="{Binding Coordinates}" Fill="Red" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<cmd:EventToCommand Command="{Binding AddDefaultCmd}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Polygon>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl> |
Quand je le fais sur un Button cela fonctionne parfaitement, il appel bien ma méthode!
Code:
1 2
|
<Button DataContext="{Binding Source={StaticResource LocatorVM}, Path=Wm1 }" Content="Add default" Command="{Binding AddDefaultCmd}"/> |
Je crois que je ne m'y prend pas de la bonne façon.
Merci par avance pour vos éclaircissements.:ccool: