SlideShare ist ein Scribd-Unternehmen logo
1 von 12
WPF Guru Award(s)Microsoft C# MVP 2009 Codeproject MVP 2009 Microsoft C# MVP 2008 Codeproject MVP 2008 C#April 2009 C#Feb 2009 Overall Feb 2009 Overall Jan 2009 C# Oct 2008 C# Feb 2008 C# Jan 2008 VS2008 comp 2007, runner up C# Nov 2007 3rd Biweekly VS2008 comp 2007 1st Biweekly VS2008 comp 2007 C# .NET July 2007 ASP .NET May 2007 C# March 2007 I was awarded the "Best IT project for 2006" award, at Sussex University, for my final year degree project, by the British Computer Society. SachaBarber WPF: A Beginner's Guide - Part 1 of n Fun With Physics WPF Diagram Designer - Part 3 XPlorerBar: A WPF Windows XP Style Explorer Bar Control Simplifying the WPF TreeView by Using the ViewModel Pattern
Configuring events & event handling Chapter 2.1
Configuring events & event handling Traditional Events still exists in WPF. Routed Events (new): Can be raised by multiple controls. Handled by multiple handlers. Add multiple levels of complexity & sophistication to your UI. Types of Routed Events Direct Events: like “MouseLeave”. Bubbling Events: like “MouseDown”. Tunneling Events: like “PreviewMouseDown”.
Configuring events & event handling Bubbling When user clicks on label MouseDown raised in Window 3 MouseDown raised in Grid 2 MouseDown raised in label 1
Configuring events & event handling Tunneling When user click on label PreviewMouseDown raised in Window 1 PreviewMouseDown raised in Grid 2 PreviewMouseDown raised in Label 3
Configuring events & event handling Demo  ,[object Object]
RoutedEventArgs
e.handled = true
e.OriginalSource & e.Source
e.RoutedEvent,[object Object]
Configuring events & event handling Attaching an Event Handler <Button Click=“button1_click”>Btn</Button> Attached Events: <Grid ButtonBase.Click=“button1_click”> <Button>Btn</Button></Grid> Me.AddHandler(Button.ClickEvent, _ New RoutedEventHandler(AddressOfClickMethod))
Configuring events & event handling EventManager Class GetRoutedEvents Returns array contains all registered routed events in the App. GetRoutedEventsForOwner Returns array contains all registered routed events for a specific element. RegisterRoutedEvent Register Instance-level event handler. RegisterClassHandler Register Class-level event handler.

Weitere ähnliche Inhalte

Ähnlich wie WPF Events

intro_gui
intro_guiintro_gui
intro_guifilipb2
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lecturesmarwaeng
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinBarry Gervin
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introductionbloodyedge03
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidgetHiron Das
 
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7Caliburn.micro jump start composite applications for WPF, Silverlight and WP7
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7Igor Moochnick
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFPaul Stovell
 
Adobe analytics implementation secret hacks
Adobe analytics implementation secret hacksAdobe analytics implementation secret hacks
Adobe analytics implementation secret hacksAlban Gérôme
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyUna Daly
 
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)Oliver Lin
 
Event handling63
Event handling63Event handling63
Event handling63myrajendra
 

Ähnlich wie WPF Events (20)

intro_gui
intro_guiintro_gui
intro_gui
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
F# And Silverlight
F# And SilverlightF# And Silverlight
F# And Silverlight
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lectures
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introduction
 
Reactive fsharp
Reactive fsharpReactive fsharp
Reactive fsharp
 
Java-Events
Java-EventsJava-Events
Java-Events
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidget
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7Caliburn.micro jump start composite applications for WPF, Silverlight and WP7
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPF
 
Adobe analytics implementation secret hacks
Adobe analytics implementation secret hacksAdobe analytics implementation secret hacks
Adobe analytics implementation secret hacks
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una Daly
 
Ppt lesson 03
Ppt lesson 03Ppt lesson 03
Ppt lesson 03
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
 
Event handling63
Event handling63Event handling63
Event handling63
 

WPF Events

  • 1. WPF Guru Award(s)Microsoft C# MVP 2009 Codeproject MVP 2009 Microsoft C# MVP 2008 Codeproject MVP 2008 C#April 2009 C#Feb 2009 Overall Feb 2009 Overall Jan 2009 C# Oct 2008 C# Feb 2008 C# Jan 2008 VS2008 comp 2007, runner up C# Nov 2007 3rd Biweekly VS2008 comp 2007 1st Biweekly VS2008 comp 2007 C# .NET July 2007 ASP .NET May 2007 C# March 2007 I was awarded the "Best IT project for 2006" award, at Sussex University, for my final year degree project, by the British Computer Society. SachaBarber WPF: A Beginner's Guide - Part 1 of n Fun With Physics WPF Diagram Designer - Part 3 XPlorerBar: A WPF Windows XP Style Explorer Bar Control Simplifying the WPF TreeView by Using the ViewModel Pattern
  • 2. Configuring events & event handling Chapter 2.1
  • 3. Configuring events & event handling Traditional Events still exists in WPF. Routed Events (new): Can be raised by multiple controls. Handled by multiple handlers. Add multiple levels of complexity & sophistication to your UI. Types of Routed Events Direct Events: like “MouseLeave”. Bubbling Events: like “MouseDown”. Tunneling Events: like “PreviewMouseDown”.
  • 4. Configuring events & event handling Bubbling When user clicks on label MouseDown raised in Window 3 MouseDown raised in Grid 2 MouseDown raised in label 1
  • 5. Configuring events & event handling Tunneling When user click on label PreviewMouseDown raised in Window 1 PreviewMouseDown raised in Grid 2 PreviewMouseDown raised in Label 3
  • 6.
  • 10.
  • 11. Configuring events & event handling Attaching an Event Handler <Button Click=“button1_click”>Btn</Button> Attached Events: <Grid ButtonBase.Click=“button1_click”> <Button>Btn</Button></Grid> Me.AddHandler(Button.ClickEvent, _ New RoutedEventHandler(AddressOfClickMethod))
  • 12. Configuring events & event handling EventManager Class GetRoutedEvents Returns array contains all registered routed events in the App. GetRoutedEventsForOwner Returns array contains all registered routed events for a specific element. RegisterRoutedEvent Register Instance-level event handler. RegisterClassHandler Register Class-level event handler.
  • 13. Configuring events & event handling Demo  Create Custom Routed Event
  • 14. How to use EventManager.RegisterRoutedEvent Sample http://www.codeproject.com/KB/WPF/WPFAjaxStyleComboBox.aspx.
  • 15. Configuring events & event handling Creating Class-Level Event Handler Using EventManger.RegisterClassLevelHandler. Raised before Instance Level Events. Application Level Events. (Application.vb)