D
D
darked2019-09-20 14:59:57
WPF
darked, 2019-09-20 14:59:57

How to filter a double click on a ListView with only the left button in WPF?

Good time of the day.
I'm trying to filter double click on ListVIew with left mouse button only:

<i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <i:InvokeCommandAction Command="{Binding Edit, Mode=OneWay}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>

But in the receiving side there is no parameter which button was clicked:
public ICommand Edit
        {
            get
            {
                return new DelegateCommand(o =>
                {
                    ApplicationController.EditReminder(SelectedReminder);
                    SaveReminders();
                });
            }
        }

I write in "pure" WPF, I don't use any third-party WPF frameworks, solutions through them are not suitable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Foggy Finder, 2019-09-20
@darked

You can go in different ways:
1. Use InputBinding , namely MouseBinding . Here LeftDoubleClick is one of the options for tracked actions, you can see the entire list here
2. Use CallMethodAction instead of InvokeCommandAction , then you can take into account the event arguments.
The method signature must be exactly the same as if you were handling the event in the View part.
3. Look for an implementation (or write it yourself) EventToCommand where the PassEventArgsToCommand method will be (with the correct implementation)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question