Kyle Delaney
Kyle Delaney

Reputation: 12274

Why do Windows Forms controls block preview events in a WPF window?

If I have a Windows Forms control like this:

        System.Windows.Forms.Button button = new System.Windows.Forms.Button()
        {
            Width = 1000,
            Height = 1000
        };

        Host.Child = button;

And I subscribe to events like this:

    PreviewStylusDown="Window_PreviewStylusDown"
    PreviewStylusUp="Window_PreviewStylusUp"
    PreviewTouchDown="Window_PreviewTouchDown"
    PreviewTouchUp="Window_PreviewTouchUp"

I thought surely my WPF window should receive the events. And yet when the button is touched, the events are never raised.

How can the Winforms control absorb a preview event like PreviewTouchDown? If it's a preview, doesn't that mean it's raised in the tunneling phase? Doesn't that mean the window should receive the event before it ever reaches the WindowsFormsHost? Just what is going on here?

Upvotes: 0

Views: 402

Answers (1)

Related Questions