I have a wpf user control that is hosted by a third party application as a non-modal dockable window. I would like to trigger an event with the window gets focus or when the mouse enters the window. This is a MVVM design. How do I bind the event handler of the Grid (not datagrid) or the UserControl to a method on the viewmodel. I want to avoid the xaml.cs code since I have to cast the datacontext into the expected viewmodel to make the call.
<UserControl x:Class="MVVMWithCommand.ChartExtentView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MVVMWithCommand"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" GotFocus="UserControl_GotFocus">
<UserControl.DataContext>
<local:MyViewModel/>
</UserControl.DataContext>
<Grid GotFocus="Grid_GotFocus">
There were two problems combined. The solution in the link didn't work because of another problem.
This only partially anwsered the question WPF Binding UI events to commands in ViewModel combined with this it did: Could not load file or assembly 'System.Windows.Interactivity'