How to use WndProc in WPF when I use the MVVM model?

Can anybody help me? I want to use WndProc in WPF, but I do not want to use it in MainWindow.xaml.cs as follows:

    public MainWindow()
    {
        InitializeComponent();
    }

    protected override void OnSourceInitialized(EventArgs e)
    {
        base.OnSourceInitialized(e);
        HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
        source.AddHook(WndProc);
        _windowHandle = source.Handle.ToInt32();
    }

I want to use it in another class, the reason is that the uEye camera is exchanging messages, and I need to "catch" them. And since I am using the ViewModel Main View model, I do not want to enter code in MainWindow.xaml.cs.

+3
source share
1 answer

MVVM does not say that you cannot write code at the presentation level. He says that you need to write code to access the Model in the ViewModel and try to make the connection between View and ViewModel as simple as possible (usually with a binding).

WndProc, "".

, , MVVM.

+3

All Articles