![]() ![]() How does one get a custom class, implemented with the handler on the Wpf platform, to behave the way NodePanel does here? Both NodePanel and NodeWindowsFormsHost bubble up properly in WinForms, while NodeWindowsFormsHost fails in Wpf.Ī second question, not directly represented in the above steps but still demonstrable with this code:.This seems to run counter to the idea of this being caused by the MouseDown event getting prematurely marked handled, since it should still show up in the list. But also worth noting is that the Events tab of WPF debugging utility Snoop shows events when clicking the menu bar, the green PixelLayout, or the cyan and purple squares, but not the white square of NodeWindowsFormsHost. Interestingly, NodeCheckBox fails to bubble on both platforms, suggesting perhaps a control implicitly marking the event handled at some point. Continue execution, and the unhandled event bubbles up as expected to MainForm.OnMouseDown. This will remove the white square and replace it with a purple one, an instance of a custom "NodePanel" class which is directly derived from Eto's Panel.Ĭlick the purple square, and the debugger will break on NodePanel.OnMouseDown. The GUI should now be running again, so click the NodePanel radio button. But continue execution further and you'll see that the event, which still hasn't been explicitly handled, fails to bubble up to MainForm.OnMouseDown. Continue execution, and the WindowsFormsHostHandler should successfully call the proper override, with your debugger breaking in NodeWindowsFormsHost.OnMouseDown, just like in step 2. The NodeWindowsFormsHost radio button should already be selected, but if not just click it.Ĭlick the white square, and your debugger should break in _MouseDown. Stop debugging, then build and run the Wpf project. Continue execution, and the as yet unhandled event bubbles up to the node's parent, with the debugger breaking in MainForm.OnMouseDown. The instance appears as a white square.Ĭlick the white square, and your debugger should break in NodeWindowsFormsHost.OnMouseDown. Click the "NodeWindowsFormsHost" radio button to add an instance of the NodeWindowsFormsHost class to the green PixelLayout. Pardon me for reiterating the test project's readme, but to keep all the info in one place:īuild and run the WinForms project from Visual Studio (really from anything, as long as a debugger is attached). The custom control's OnMouseDown override is successfully called, but the event vanishes after that, even if e.Handled is expressly set to false. Mouse events raised by a custom control, in this case based on a WindowsFormsHostHandler handler in WPF, will bubble up to their parent if not explicitly marked handled. ![]() There's some related info in #542, but I think that's a little long in the tooth. I can see this turning out to not be a bug, but for the sake of anyone else who runs into this I thought an issue would the right place to discuss the finer points. At the root of #1419, and seemingly a variation on an issue I've run into before, I'm having trouble understanding event bubbling in the Wpf platform. ![]()
0 Comments
Leave a Reply. |