routed-events

How to make a ButtonSpinner's buttons not close the Popup in which it is placed?

最后都变了- 提交于 2020-02-07 05:21:51
问题 I have a RepeatButton inside the template of a ButtonSpinner inside a Popup. When I click it, I want the Popup to remain open but it closes. The reason for which I use this template is exactly to solve this issue. Screenshot: The OnMouseLeftButtonUp event handler marks the MouseLeftButtonUp event as handled here. I thought about using e.Handled = true in an event handler, but I am not sure about it and that the order of events is this: PreviewMouseLeftButtonDown MouseLeftButtonDown

The event 'foo' is not a RoutedEvent

我的梦境 提交于 2020-01-15 10:15:18
问题 I tried making a Routed Event in a user control of an existing project and I'm getting the error message The event 'foo' is not a RoutedEvent. To make sure I wasn't crazy, I made an example project with just the offending code (a Minimal, Complete, and Verifiable example"). Only I don't get any error message in my example project. But it's the exact same code! Does anyone have any ideas what's going on? Even with the error message, the project compiles and the RoutedEvent works! I tried

The event 'foo' is not a RoutedEvent

偶尔善良 提交于 2020-01-15 10:15:12
问题 I tried making a Routed Event in a user control of an existing project and I'm getting the error message The event 'foo' is not a RoutedEvent. To make sure I wasn't crazy, I made an example project with just the offending code (a Minimal, Complete, and Verifiable example"). Only I don't get any error message in my example project. But it's the exact same code! Does anyone have any ideas what's going on? Even with the error message, the project compiles and the RoutedEvent works! I tried

WPF: Routed events or regular events?

若如初见. 提交于 2020-01-14 07:30:35
问题 In WPF we have routed events. When should these be used instead of regular events? 回答1: Routed events have special behavior, but that behavior is largely invisible if you are handling an event on the element where it is raised. Where routed events become powerful is if you use any of the suggested scenarios: defining common handlers at a common root, compositing your own control, or defining your own custom control class. Routed event listeners and routed event sources do not need to share a

Handling a bubbling event raised from a modal dialog in main window

霸气de小男生 提交于 2020-01-05 05:43:08
问题 I have a modal dialog in my WPF application that allows a user to login to a server. The dialog simply contains a User Control that handles all the login stuff (UI, web service call, and raising a routed event when the call returns). All works nicely and I can handle my event in the dialog (close the dialog when login successfull). However, I am not able to handle the event in my main application (I should refresh the UI once the user has logged in). How can one intercept such routed events

Checking if a RoutedEvent has any handlers

本小妞迷上赌 提交于 2020-01-01 06:27:56
问题 I've got a custom Button class, that always performs the same action when it gets clicked (opening a specific window). I'm adding a Click event that can be assigned in the button's XAML, like a regular button. When it gets clicked, I want to execute the Click event handler if one has been assigned, otherwise I want to execute the default action. The problem is that there's apparently no way to check if any handlers have been added to an event. I thought a null check on the event would do it:

Checking if a RoutedEvent has any handlers

我的未来我决定 提交于 2020-01-01 06:27:17
问题 I've got a custom Button class, that always performs the same action when it gets clicked (opening a specific window). I'm adding a Click event that can be assigned in the button's XAML, like a regular button. When it gets clicked, I want to execute the Click event handler if one has been assigned, otherwise I want to execute the default action. The problem is that there's apparently no way to check if any handlers have been added to an event. I thought a null check on the event would do it:

Why is the TextBlock not the OriginalSource on the Routed Event?

帅比萌擦擦* 提交于 2019-12-31 03:05:12
问题 I'm showing a context menu for elements in a ListView . The context menu is attached to the TextBlock s of the ListView as follows. <ListView.Resources> <ContextMenu x:Key="ItemContextMenu"> <MenuItem Command="local:MyCommands.Test" /> </ContextMenu> <Style TargetType="{x:Type TextBlock}" > <Setter Property="ContextMenu" Value="{StaticResource ItemContextMenu}" /> </Style> </ListView.Resources> The context menu properly shows up and the RoutedUIEvent is fired as well. The issue is that in the

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

天大地大妈咪最大 提交于 2019-12-31 01:00:55
问题 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! 回答1: 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

Not able to handle PreviewMouseDown

ⅰ亾dé卋堺 提交于 2019-12-24 08:34:46
问题 Hey; I have the following visual hyerarchy in a usercontrol: Grid -> Canvas -> MyContentControl MyContentControl is a class derived from ContentControl that has an adorner on top that is a rectangle, this is to make it easier to click on certain objects (increase hit testing area). The adorner is present at all times, but with transparent background. I would like to see the PreviewMouseDown events raised when I click on a MyContentControl from the usercontrol's codebehind, but the event does