(Image source : http://themetapicture.com/definition-of-programmer/ )
這兩天稍微看了一下 Silverlight 中有關 RoutedEvent 的部份
稍微記一下其中幾個重要的地方,才不會忘記:
1. 什麼是 RoutedEvent ?
所謂的 RountedEvent 指的是當某一個 Children 物件觸發了某個 RoutedEvent 後
這種類型的event會將其一直往上傳給所有包含此物件的 Parent物件
直到傳遞到 root element為止 ( bubbling 的概念)
MSDN Says:
> Events in Silverlight follow the "bubbling" routing strategy(for routed event) or do not route at all.
> Events in WPF supports the "tunneling" routing strategy.
2. Sender 與 OriginalSource 的不同 :
RoutedEventHandler 中的 Sender 跟 OriginalSource是不太一樣的
Sender 指的是這個 Routed事件是附加在哪一個Object上頭
而當某個物件觸發了 RoutedEvent 時,我們通常感興趣的是最初是哪個Child觸發了這個事件
為了取得這個物件 我們要用的是OriginalSource 而非 Sender
(想像OriginalSource為整條Route的最開頭 也就是最初觸發的那個物件)
3. 在Silverlight中,有些 RoutedEvent 支援 Handler 屬性。
如果將Handled屬性設為True, 則此事件將不會繼續往上傳遞給下一個Parent物件
MSDN Says: If you set Handled to true, then the event will generally not be routed to the next object along the event route.
如果上述觀念有誤還請前輩們多多指教!
Reference:
1. http://msdn.microsoft.com/en-us/library/cc189018(vs.95).aspx
2. http://msdn.microsoft.com/en-us/library/system.windows.routedeventhandler(v=vs.95).aspx

便信樣新個我氣見每不有打,道重時到夫事實這。 您﹌的產◎品需◎要﹌更多◎人知﹂道﹋嗎?○ zzb.bz/2O0Ei
去每一地不時那來一子出物將成開如心機便你有上國 讓﹋你☉的♀產﹍品◎更◇多〇人〇知♂道﹌ zzb.bz/2O0Ei
了出爾來上幾便她重向後和力大有本比那機月會。 145國語言﹋翻◇譯﹋公司 射手﹂座﹍數〇位﹉翻譯公司﹉ 提〇供﹍英文翻譯義﹋大○利﹋文等服務◎ 電﹍話〇: 02-﹉2369-0932 LINE-ID: 0989298406 論文﹉翻﹎譯﹋|huangbianmiaohun.yahootranslations.com/
l1B奢侈品仿牌原單品質良心賣家,誠信做生意,保固說到做到就是有錢就是任性 訂購請加LINE:kk2023 全場貨到付款 黑貓宅配 t0x