Click here to Skip to main content

Silverlight / WPF

 
GeneralRe: WPF controls refresh Pinmembercaradri3-Feb-13 21:16 
QuestionRoutedEvent vs AttachedEvent Pinmemberdevvvy29-Jan-13 23:30 
AnswerRe: RoutedEvent vs AttachedEvent PinprotectorPete O'Hanlon29-Jan-13 23:51 
GeneralRe: RoutedEvent vs AttachedEvent [modified] Pinmemberdevvvy30-Jan-13 0:02 
Pete O'Hanlon wrote:


So, what is an attached event? Well, basically, it's an event that can be attached to another element without the other element having to be aware that this capability is present. If you think about it as being like an attached property for events then it starts to make sense. So, why do we have this? Well, it allows you to extend WPF through composition rather than inheritance.

 
I understand perfect "Grid.Row" is an "Attached Property" that it's not a property of "TextBox" itself for instance. I understand analogy when this concept extended to "Events". However - what's confusing is the SYNTAX: you can define an event handler to a RoutedEvent the same way/syntax as you would with AttachedEvent.
 
But if you see the sample I gave in MainWindow.xaml, I can subscribe to "AttachedEvent" and "RoutedEvent" from xaml in same syntax - the syntax which does not require "Instance" of "GrandChild" (i.e. "MainWindow" does NOT implement event GrandChildRoutedEvClick itself, which is declared in "GrandChild")
 
From MainWindow.xaml, "RoutedEvent" handler setup like this:

local:GrandChild.GrandChildRoutedEvClick="GrandChild_GrandChildRoutedEvClick"

 
From MainWindow.xaml, "AttachedEvent" handler setup like this:

local:GrandChild.GrandChildAttachedEvClick="GrandChildAttachedEvClickHandler"

 
Despite in "MiddleChild.xaml", I setup handler to "RoutedEvent" the "Propery way"... what's real diff between Routed/AttachedEvent besides phylosophical or syntactical ...?

[local:GrandChild x:Name="Junior" VerticalAlignment="Stretch" GrandChildRoutedEvClick="GrandChild_GrandChildRoutedEvClick"/]


What I am saying is, you can define a DockStateChanged event with syntax of a "RoutedEvent" - not "AttachedEvent", and in some parent control couple layers up, setup event handler using syntax as you would consuming an "AttachedEvent"

dev


modified 30-Jan-13 5:11am.

GeneralRe: RoutedEvent vs AttachedEvent PinprotectorPete O'Hanlon30-Jan-13 1:45 
GeneralRe: RoutedEvent vs AttachedEvent Pinmemberdevvvy30-Jan-13 3:40 
GeneralRe: RoutedEvent vs AttachedEvent PinprotectorPete O'Hanlon30-Jan-13 3:44 
GeneralRe: RoutedEvent vs AttachedEvent Pinmemberdevvvy30-Jan-13 4:08 
QuestionWPF Tab Item Close Button [modified] PinmemberKevin Marois29-Jan-13 19:03 
AnswerRe: WPF Tab Item Close Button PinmemberSledgeHammer0129-Jan-13 20:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 30 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid