Andreas Larsen
Andreas Larsen

Reputation: 13

Mvvm light EventToCommand - Setting the Handled property?

I have a tabbed GUI with each tab containing a Frame. I use the EventToCommand with the SelectionChangedEvent whenever a new TabItem is selected. I do this to update the state of the app. This all works fine - a little bit too fine, the event gets fired too often. Here is my problem:

How can I prevent the event from bubbling up the visual tree by setting the Handled property on the event when using the mvvm light eventToCommand feature?

Upvotes: 1

Views: 622

Answers (1)

Maximus
Maximus

Reputation: 3448

<i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseLeftButtonDown">
        <mvvm:EventToCommand
            Command="{Binding YourCommand}"
            PassEventArgsToCommand="True" />
    </i:EventTrigger>
</i:Interaction.Triggers>

Your command needs to provide parameter from method like RelayCommand . This parameter is event args providing Handled property. More here.

Upvotes: 0

Related Questions