eventsetter

Fire a template child event in current context?

Hello. Is there a way to fire an event from a visual within a DataTemplate in the current context (i.e. Page, Window, UserControl etc.). For example I have a DataTemplate that contains a button or a ListBox. I want that when the button is clicked or when ListBox.SelectionChanged is fired in the ListBox, the event handler should be decl...

WPF: How do I use EventSetters with a Window Style?

I have styled a window to replace the standard Chrome and I want to handle the Activated and Deactivated events using EventSetters. I get an error "...'Activated' must be a RoutedEvent registered..." with this: <EventSetter Event="Activated" Handler="Window_Activated"/> However, this works fine in the same style. <EventSetter Ev...

WPF: Using a button as a DataTemplate, how to add click event

I have a ItemsControl with a collection of objects. I wan't to be able to click the object and then get a panels with more info. So I decided to style the DataTemplate for the items in the ItemsControl as a button and that seems to work fine. However I have no idea how to set the click event of this button in the style. It says I should...

Assigning a command to the EventSetter

Hello, How to assign a command to the Handler in EventSetter, I want to to write this: <Style x:Key="ItemStyle" TargetType="{x:Type ListBoxItem}"> <EventSetter Event="PreviewMouseDoubleClick" Handler="{Binding MyDoubleClickCommand}"/> ...