Bonjour.

Je n'arrive pas à comprendre comment utiliser les trigger :

XALM :
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
 
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
 
...
 
<Rectangle Width="300" Height="100" Fill="#FFBD3939">
	<i:Interaction.Triggers>
		<i:EventTrigger EventName="MouseEnter">
<!--
			<i:InvokeCommandAction Command="{Binding HoverOnRecCommand}"/>
-->						
			<i:InvokeCommandAction CommandName="HoverOnRecCommand"/>
		</i:EventTrigger>
	</i:Interaction.Triggers>
</Rectangle>
 
 
<Button  Command="{Binding LoadCustomersCommand}" 
           Content="Load Customers" Height="25" Margin="380,267,20,8" />

Model :
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
21
22
23
 
public DelegateCommand<string> MyCommand { get; set; }
void MyCommand_Execute(string text)
{
	int i = 0;
	i = i + 1;
}
 
 
 
public DelegateCommand<object> LoadCustomersCommand { get; set; }
private void LoadCustomers(object parameter)
{
	int i = 0;
	i = i + 1;
}
 
 
public BrowserViewModel( )
{
	this.MyCommand = new DelegateCommand<string>(MyCommand_Execute);
	this.LoadCustomersCommand = new DelegateCommand<object>(LoadCustomers);
}
Quand j'utilise la propriété "Command", la compilation se passe bien, mais génère une exception. La fonction existe bien dans le model.

La propriété pouvant être attachée 'Triggers' est introuvable dans le type 'Interaction'. [Line: 25 Position: 28]
Le binding pour le bouton se passe bien, la commande LoadCustomersCommand est bien appelée.