Reputation: 18465
sorry for this probably simple question but I don't understand how binding works. In the following XAML code I would like to pass my rectangle name as command parameter. I would like to pass "Color01".
<Rectangle x:Name="Color01" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="100" Margin="10,29,0,0" Stroke="Black" VerticalAlignment="Top" Width="100">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding MyCommand}" CommandParameter="{Binding ???}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Rectangle>
What should I write in my binding ???
Upvotes: 1
Views: 1018
Reputation: 81253
You can pass Name using RelativeSource
markup extension:
CommandParameter="{Binding Name, RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=Rectangle}}"
Upvotes: 3