routed-events

In WPF, is it possible to specify multiple routed events for a single event trigger?

I have an event trigger that I want to be fired in response to two different routed events. I don't want to repeat the event response code (in XAML) twice. Can I specify multiple routed events for a single event trigger declaration? Example of a single event: <Style.Triggers> <EventTrigger RoutedEvent="Button.MouseEnter"> ...

Silverlight RoutedEvents and Exceptions

I have a complex application that consists of an Application, containing many modules, each containing many views. The behaviours of my views may throw exceptions. Sometimes I want to handle exceptions on the view that created them, sometimes in the parent module, sometimes in the grand-parent application. The concept of RoutedEvents s...

Routed events in wpf

Hi, A very well known fact is that routed events only travel up or down the ancestry and not through all the elements. But an equally known fact is that an event handler can be wired in the common parent of two disparate controls. My questions is how, some pointers please. I have XAML that looks like <Grid Name="MainGrid"> <Lis...

WPF RoutedEvents Being Handled By...?

I have a 3D application in WPF which basically is supposed to zoom in and out as the MouseWheel event is fired. I have attempted to subscribe everything possible, but can't find what it is which is handling it. Is there a way to find out what is? Or is there a way to have the event not handled, or for an encompassing UIElement to get to...

WPF: Routed events or regular events?

In WPF we have routed events. When should these be used instead of regular events? ...

LeftMouseButtonDown is not working with buttons in routed events

Hi, I was learning about routed events in wpf and I tries the following example, File -- Window1.xaml <ScrollViewer VerticalScrollBarVisibility="Auto"> <UniformGrid MouseDown="UniformGrid_MouseDown"> <Button x:Name="Button1">1</Button> <Button x:Name="Button2">2</Button> <Button x:Name="Button3">3</But...

Is there a way to watch WPF Routed Events?

I was wondering if there's a way to watch all RoutedEvents that are raised in a WPF application. A way to write some info about the events fired to the console would be prefect to see what's going on. ...

WPF and routed event

I have a WPF window, which has a button that is inside a stackPanel, which is inside another stackPanel I wrote an event handler for the button for the MouseDown event. I want to execute this eventHandler three times for the button and the parent (stack panel) and the parent's parent How can I achieve that with the routed event, by wri...

Bubbling RoutedEvent or RoutedCommand to a ViewModel

I've got a collection of ViewModels that are rendered as tabs using a style to pull out the relevant content to display on the tab: public class TabViewModel : DependencyObject { public object Content { get { return (object)GetValue(ContentProperty); } set { SetValue(ContentPropert...

How to ensure that the top level WPF "Window" element handles TextInput RoutedEvents?

I've got an application that traps text entry at the window level (i'm using a barcode scanner) and occasionally the operator will click on view elements which then gain focus, taking focus off the window, and the window no longer recieves either previewtextentry or textentry events, any ideas? ...

WPF MVVM Routed Events

Hi everyone, There are a lot of discussions about M-V-VM and Command binding (RelayCommand) but not a lot has been covered on Routed Events binding to a handler in a M-V-VM pattern. I want to find what is the best approach. Here is an example of RoutedEvent binding using a custom event and a bound event handler to the VM. <Navigation:...

Disable Return key outside textareas on a Asp.Net web page (containing ajax code)

Hi, I have an Asp.Net web page, having the common Asp.Net form. The outer "border" of the page (i.e. main menu, header, ...) is build using normal Asp.Net code using a master page. The content of that page uses jQuery to display dynamic forms and to send data to the server. If I push the return key on that page, I jump to a (more or le...

Command Binding Memory Leak in WPF

When i create a user control that has a CommandBinding to a RoutedUICommand im worried that i get memory leaks. scenario: Have a RoutedUICommand as a static in c class where i store my commands Implement the CommandBindings on a user control. Add the user control to the main form. Remove the user control from the main form, set the re...

WPF: Custom routed event with extra information

I have a normal WPF window, let's call it TopLevel which has a bunch of controls in it, among other things a simple ListView which should log certain events in different elements in the application. So suppose I have a Grid in TopLevel which contains a bunch of user controls called Task. Each Task has an object associated with them as a...

WPF Style Override breaks Validation Error event propagation

I have a custom control that overrides Window: public class Window : System.Windows.Window { static Window() { DefaultStyleKeyProperty.OverrideMetadata(typeof(Window), new System.Windows.FrameworkPropertyMetadata(typeof(Window))); } ... } It also has a style: <Style TargetType="{x:Type ...

Checking if a RoutedEvent has any handlers

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 defaul...

MS Surface Tag Visualizer steals contact events

I'm struggling with the TagVisualizer control on an MS Surface project. In theory the control seems great, allowing you to respond to input from real world physical objects The problem is that the control will cover the entire screen (since I want to capture tags on the entire screen) and as such, no other controls in my app will receiv...

TextChanged Events - Why does this not result in an infinite loop?

While trying to do something a bit more complicated, I ran across a behavior I don't quite understand. Assume the following code below handling the textChanged event. private void textChanged(object sender, TextChangedEventArgs e) { TextBox current = sender as TextBox; current.Text = current.Text + "+"; } No...

How do I swallow the dropdown behavior inside an Expander.Header?

Hello, I would like to prevent an Expander from expanding/collapsing when users click inside the header area. This is basically the same question as Q 1396153, but I'd appreciate a more favorable answer :) Is there a non-invasive way to do this? I am not sure exactly how to attach behavior to the Expander.Header content to prevent mous...

raising events passing parameters in wpf

Hi, I'd like to add tabs to my window when an item in the GridView is double-clicked. But the tab that will be added depends on the clicked item. Which way should I do this on WPF? I thought about RoutedEvents, but I don't know how to pass a parameter with it. Any suggestions? ...