« MouseBinding » : différence entre les versions
De Banane Atomic
Aller à la navigationAller à la recherche
(Page redirigée vers InputBindings) Balise : Nouvelle redirection |
(Redirection supprimée vers InputBindings) Balise : Redirection supprimée |
||
Ligne 1 : | Ligne 1 : | ||
[[Category:WPF]] | |||
= Links = | |||
* [http://www.blackwasp.co.uk/WPFMouseBindings.aspx Mouse binding] = | |||
= Mouse binding = | |||
<filebox fn='MyView.xaml'> | |||
<TextBlock Text="{Binding Name}"> | |||
<TextBlock.InputBindings> | |||
<MouseBinding MouseAction="LeftDoubleClick" | |||
Command="{Binding EditCommand}" | |||
CommandParameter="{Binding}" /> | |||
</TextBlock.InputBindings> | |||
</TextBlock> | |||
</filebox> | |||
<filebox fn='MyViewModel.cs'> | |||
public ICommand EditCommand { get; } | |||
public MyViewModel() | |||
{ | |||
EditCommand = new DelegateCommand<Item>(Edit); | |||
} | |||
private void Edit(Item item) | |||
{ | |||
} | |||
</filebox> |
Version du 20 octobre 2021 à 08:40
Links
Mouse binding
MyView.xaml |
<TextBlock Text="{Binding Name}"> <TextBlock.InputBindings> <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditCommand}" CommandParameter="{Binding}" /> </TextBlock.InputBindings> </TextBlock> |
MyViewModel.cs |
public ICommand EditCommand { get; } public MyViewModel() { EditCommand = new DelegateCommand<Item>(Edit); } private void Edit(Item item) { } |