ContactUp event not fired - wpf

In my surface application I have a SurfaceWindow with a SurfaceUserControl on. On the SurfaceUserControl I have a SurfaceButton but the ContactUp (and down) event is not fired. The ContactHoldGesture event is fired though.
Any ideas?

Could you include some code to reproduce? Where are you subscribing to those events?
Most likely what's happening is the contact up and down events are being handled by the button, so they don't fire at the usercontrol level. Try looking at the previewcontactup and previewcontactdown events.

ContactUp and ContactDown are handled by the button itself - that's why the events never get to your code. If you really want to intercept these events, use PreviewContactUp/PreviewContactDown instead. What you probably really need though is to just handle the Click event on the button. Adjust the ClickMode property of the button if you want to change what causes the Click event to be raised.

Related

ExtJS 6 Check if event was fired programmatically

How I can check if event was fired programmatically?
Namely I have an Ext.tree.Panel and listen for it selectionchange event. How I can check within handler if event was fired manually by user (row click) or via select() method?
option 1 :
For most of the events eOpts arguments is passed to event. Depending on the event this is fill by ExtJs. If event is fired manually thus eOpts is never filled or filled customly.
option 2:
If manual event firing is happens in code you can manipulate add a custom argument
As far as I know and my research there is no solution based on scope of selectionchange event. However from a design perspective this is how it should be since selectionchange event should not depend on caller. From what is told I can say that 2 different event is needed. Where different action is taken. (which is the definition of an event :))
Therefore my suggestion is to override select method and fire a custom event in which you do what you want do differently. If needed in rowclick event another custom event can be fired.
You can override this in subclasses or you can use Ext.override for global scope.
You can't, really. The "best" way would be to listen for an itemclick event and check whether the selectionchange event fired within some small threshold amount.

PreviewMouseDown Intercepting SelectedItemChanged Event

I've got a TreeView which acts as the main way of navigating a WPF application.
When the user selects a new item in the TreeView if the page they're leaving has unsaved information we offer the chance to cancel the move to continue working on the current data/save it. This currently happens in the PreviewMouseDown event handler.
It seems however that throwing up a dialog that offers a yes/no/cancel option here prevents the SelectedItemChanged event from ever actually firing, I assume because another mouse click has occured. As a result, if they decline the option to stay on the current page, it's still not changing.
Is there any way to re-fire the event from within PreviewMouseDown so that the SelectedItemChanged event still gets called?
Is there any way to re-fire the event from within PreviewMouseDown so that the SelectedItemChanged event still gets called?
It would be easier to call the event handler manually just as you would call a method. Or better yet, break out the code in the event handler to a standalone method that you call from both the PreviewMouseDown handler and the SelectedItemChanged handler.
The other option would be to change the SelectedItem or IsSelected property so the event fires again.

Strange issue - mouse click in popup is getting captured by control underneath

I'm displaying a Popup in response to a button click (popup.IsOpen = true;). The popup contains a ComboBox, and when I click an item in the combobox, one of the things the SelectionChanged event does is to hide the popup.
The Popup appears over a DataGrid that I also have on my page, and I'm finding that the mouse-click on the combobox is also being picked up by a MouseUp event that I've got on the DataGrid. Any idea what's going on?
The MouseUp Event has a routing strategy of type Bubbling. Events that use this type of strategy get passed up the chain to parent controls. Since the Popup is a child of the DataGrid, the event will "bubble" up to the DataGrid. If you would rather the event not bubble, you can try using PreviewMouseUp, which has a Tunneling routing strategy, and will "tunnel" down the chain to child controls. Here is a decent overview of Routing Strategies.
I've hit the same issue. Oddly, it doesn't happen when the code is run in the debugger - it only happens in the release version. It really seems to be a bug in WPF. Trying to catch the click and set the event to handled doesn't work.
My workaround is to, when the popup opens, to tell the control underneath to ignore the click.

Understanding Routing Events: Why I need both, bubble and tunnel events?

I read this good article about Routed Events, and I understood why we need sometimes bubble Events and sometime we need tunnel Events.
What I didn't understand is, when we use the tunnel Event, why after it is handled or reached to the source element, still the bubble event is launched?
Thanks in advance!
The article says that if you put an image on a button, and that image is clicked, the tunnel event for that image will fire. But it is highly likely that you would also want to handle that click as if the button itself was clicked, so a bubble event is also fired which bubbles up to the click event on the button itself (because the button owns the image), so that you can treat the image click like a button click, using the usual event handler for the button.
I would also like to add that the event for both (Tunnel and Bubble) are different.
For tunnel, we use PreviewXXX (eg: PreviewMouseDown) and for bubble event we use XXX (eg: MouseDown) event.
By sequence, Tunnel event gets fired first starting from the root of the application and ends at the source. And the Bubble event is triggered.
It makes perfect sense to have both these events.

DataGrid.LoadingRow event firing three times

I have a HyperLinkButton in every row of a datagrid in my silverlight app. I need to fire an event so I am adding a handler to the click event of the HyperLinkButton in the DataGrid.LoadingRow event. The problem is the event is firing three times (more accurately, the handler is being added three times. I tried removing the handler before adding it but that has no effect. Any ideas?
I just set the .Tag on the Hyperlink button when I add the event handler and use that as a flag that the handler has been added.
To add to this issue, the problem occurs probably because the LoadingRow event may actually fire several times. The Datagrid will only instantiate the row when it is needed and will recycle it when it goes out of view. Like when you start scrolling the grid.
See the remarks sections for details:
DataGrid.LoadingRow event on msdn

Resources