Posts

Showing posts with the label Interactivity

How to use Interaction Triggers to handle user-initiated events in WPF / MVVM

Image
Example scenario: User clicks the mouse in a WPF application - how do we 'listen' to that event in order to trigger and handle an event in the main code? A possible solution is to use in WPF MVVM. See this post to learn how to do this using MvvmLight: https://www.technical-recipes.com/2017/handling-mouse-events-in-wpf-mvvm-using-mvvmlight-event-triggers/ Here is an example WPF implementation created in Visual Studio 2015. Step 1: Create a WPF application Step 2: Add the System.Windows.Interactivity reference UPDATE For more recent versions of .NET see this StackOverflow post on how to upgrade from older versions of Interactivity to the latest NuGet package: https://stackoverflow.com/questions/8360209/how-to-add-system-windows-interactivity-to-project/56240223#56240223 If you need to migrate from an older version, then do these steps: 1. Remove reference to “Microsoft.Expression.Interactions” and “System.Windows.Interactivity” 2. Install the Microsof...