routed-events

Click event for controls below other controls

Hello, I have two controls A and B. Control B is placed over A. When B is clicked only it's clicked event is fired, however I need the click event of A to fire too. Can this somehow be realized using routed events? Here's a screenshot of the controls: Of course this case is just a reduced example, I'm looking for a general way to ra...

WPF - Custom Mark-up Extensions return RoutedEvents

Hello! I'm trying to create a generalized event for my Close buttons, where they have to close the window but before that set focus to the owner window. I don't want to have an event for every file for that, because that'd be pretty unpractical since I have 30+ windows in my application. (So if I wanted to change that behavior, i'd have ...

Raising ContextMenuClosing event manually

Hello, I'm deriving from ContextMenu and inside the derived class I need to raise the ContextMenuClosing event manually. I tried the following two ways: // On runtime tells me it can't convert from // "System.Windows.RoutedEventArgs" to // "System.Windows.Controls.ContextMenuEventArgs" RaiseEvent(new RoutedEventArgs(ContextMenuClosi...

Using Preview events

WPF defines most routed events in pairs, we have both Bubbling and tunneling events. I have seen people using Preview(tunneling) events for performing the operations instead of using the bubbling ones. As per my understanding preview events should only be used to perform some checks and/or handle the event if required. Is it a good pra...

WPF - Events on a ControlTemplate?

Does anyone know why I can't set an event on a control template?? For example, the following line of code will not compile. It does this with any events in a control template. <ControlTemplate x:Key="DefaultTemplate" TargetType="ContentControl"> <StackPanel Loaded="StackPanel_Loaded"> </StackPanel> </ControlTemplate> I am usin...

How to fire new SelectionChanged Event

Hi. I'd like to fire a SelectionChangedEvent. What I have is this: Fluent.ComboBox fcb = elt as Fluent.ComboBox; fcb.RaiseEvent( new SelectionChangedEventArgs( null, new List<double>() { (double)fcb.SelectedItem }, new List<double>() { fontSize }) ); My question is what I have to insert for the null parameter. The constructor expe...

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

Hi all, 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! ...

Routed Events in WPF - using an Action delegate

Hi, I'm developing a user control, and wish to use a routed event. I notice that there are two delegates provided - RoutedEventHandler, and RoutedPropertyChangedEventHandler. The first that doesn't pass along any information, and the second that takes the old and new values of a property change. However, I need to pass just a single p...

Events routing in WPF.

Hi there, I have implemented a UserControl. Then I would like to handle an event that is originally handled by Window (keyboard press). What is the best way to route the event caught by another component (higher in the components' tree)? Thanks in advance for the replies and hints! Cheers ...

Raising RoutedEvents in non-UIElement class

It seems that the entire power of routedevents is directed towards UI development. Meaning to ask, would it be possible to raise a routed event from a class that does not extend a UIElement or UserControl class at all? For example: I create a State class that I that performs several changes on some data (mainly drawings and objects) and ...

WPF - understanding RoutedEvents

Hi I'm learnign WPF and currently I'm reading about RoutedEvents. In book "Pro WPF in c#" there is some snipet of code which I present below <Window x:Class="RoutedEventsLearning.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" ...