MVVM-Samples icon indicating copy to clipboard operation
MVVM-Samples copied to clipboard

EventToCommand in this MVVM Toolkit

Open luetm opened this issue 2 years ago • 2 comments

Hey!

We're migrating our WPF solution to core and noticed that the Galasoft MVVM Toolkit seems to have been superseded by this one. One problem that came up is how to express this kind of example ..

xmlns:cmd="clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
<!-- ... -->
<Border>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseLeftButtonDown">
            <i:InvokeCommandAction Command="{Binding ItemSelectedCommand}" CommandParameter="{Binding}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</Border>

in this new framework. There is a sample in the docs that uses a interactions namespace but never explains where this namespace comes from (probably it's not even WPF). Also there doesn't seem to be a WPF sample app.

Is WPF even supported? If so, how can we do this kind of thing?

Thanks!

luetm avatar Aug 30 '21 08:08 luetm

Hi @luetm, those XML namespaces are from the XAML Behaviors packages, which are available for WPF as well. You can check them out in their official repo. They are available on NuGet through the Microsoft.Xaml.Behaviors.Wpf package.

So yeah, the sample you see there should work just fine on WPF as well That said, you make a good point there, we should definitely update the docs to mention the behaviors packages to make things clearer in the future 🙂

Sergio0694 avatar Aug 30 '21 12:08 Sergio0694

By the way, In the WinUI3 era, the XAML binding command still requires 6 lines of code.😱

CodingOctocat avatar Jul 12 '22 13:07 CodingOctocat