Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Simulate double click event is not propagating visual tree

$
0
0

I need to raise mouse double click event when a button is clicked on the same control. I have a double click event handler at the parent and at this control. But the handler at the parent is called only when I manually double click and not when I programmatically raise it. What am I missing?

My code

private void RaiseDoubleClickEvent()
{
MouseButton mouseButton = MouseButton.Left;
MouseButtonEventArgs doubleClickEvent = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, mouseButton);
            doubleClickEvent.RoutedEvent = ContentControl.MouseDoubleClickEvent;

            doubleClickEvent.Source = this;
            RaiseEvent(doubleClickEvent);
}

Any help appreciated.

Update 1:

I have complex setup. My control is a user control (c1). It is part of another parent user control(c2). This c2 is inserted dynamically into another custom grid control which is part of higher parent user control(c3). When it is inserted into the custom grid, grid subscribes to its double click event. So grid has the event handler. That event handler is fired when user manually double clicks on the control c1. But my new requirement is that when a button is clicked on c1, that double click event handler should be called. That's why I'm raising the event on the button click on c1.

I'm not using e.Handled any where in the double click handlers.

Hope this helps. 





Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>