« MouseBinding » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
(Redirection supprimée vers InputBindings)
Balise : Redirection supprimée
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
[[Category:WPF]]
[[Category:WPF]]
= Links =
= Links =
* [http://www.blackwasp.co.uk/WPFMouseBindings.aspx Mouse binding] =
* [http://www.blackwasp.co.uk/WPFMouseBindings.aspx Mouse binding]


= Mouse binding =
= Mouse binding =

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)
{
}