Bonjour.

Je voudrais savoir si il est possible de faire passer la référence de l'objet au quel est attaché un trigger. J'ai essayé plusieurs méthodes, mais à chaque fois le paramètre passé à la méthode MyMouseLeaveCommand est NULL.


XALM Code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
<Rectangle Name="rectangle1" Fill="#FFBD3939" Height="100" Margin="49,61,51,139" Width="300">
 <i:Interaction.Triggers>
  <i:EventTrigger EventName="MouseEnter">
   <i:InvokeCommandAction Command="{Binding MyMouseEnterCommand}" CommandParameter="#FFBD3939"/>
  </i:EventTrigger>
  <i:EventTrigger EventName="MouseLeave">
   <!--
   <i:InvokeCommandAction Command="{Binding MyMouseLeaveCommand}" CommandParameter="#FF39BD39"/>
   -->
   <!--
   <i:InvokeCommandAction Command="{Binding MyMouseLeaveCommand}" CommandParameter="{Binding rectangle1}"/>
   -->
   <!--
   <i:InvokeCommandAction Command="{Binding MyMouseLeaveCommand}" CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>
   -->
   <i:InvokeCommandAction Command="{Binding MyMouseLeaveCommand}" CommandParameter="{Binding rectangle1}"/>
  </i:EventTrigger>
 </i:Interaction.Triggers>
</Rectangle>
Modèle Code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public DelegateCommand<object> MyMouseLeaveCommand { get; set; }
 
void MyMouseLeaveCommand_Execute(object param)
{
 if (param != null)
 {
  MouseEvt = "Mouse Leave : " + (param as string);
 }
 else
 {
  MouseEvt = "Mouse Leave : null";
 }
 
 OnNotifyPropertyChanged("MouseEvt");
}
Merci.