Click here to Skip to main content
       

Silverlight / WPF

 
GeneralRe: WPF - Bind IsEnabled To Method On VM PinmemberKevin Marois20-Jan-13 8:47 
QuestionWPF - Sync Combox [modified] PinmemberKevin Marois12-Jan-13 15:19 
AnswerRe: WPF - Sync Combox PinmemberMycroft Holmes13-Jan-13 0:50 
GeneralRe: WPF - Sync Combox PinmemberKevin Marois13-Jan-13 17:24 
GeneralRe: WPF - Sync Combox PinmemberMycroft Holmes14-Jan-13 0:11 
GeneralRe: WPF - Sync Combox PinmemberKevin Marois14-Jan-13 5:25 
GeneralRe: WPF - Sync Combox PinmemberSledgeHammer0114-Jan-13 9:34 
GeneralRe: WPF - Sync Combox PinmemberKevin Marois23-Jan-13 17:41 
QuestionStyle From Resource File Not Being Applied PinmemberKevin Marois12-Jan-13 10:20 
AnswerRe: Style From Resource File Not Being Applied PinmvpRichard MacCutchan12-Jan-13 23:44 
GeneralRe: Style From Resource File Not Being Applied PinmemberMycroft Holmes13-Jan-13 0:45 
GeneralRe: Style From Resource File Not Being Applied PinmvpRichard MacCutchan13-Jan-13 1:24 
GeneralRe: Style From Resource File Not Being Applied PinmemberKevin Marois13-Jan-13 10:58 
QuestionRoutedEvent vs AttachedEvent - Syntax difference only? Confused [modified] Pinmemberdevvvy9-Jan-13 20:05 
Following example I managed to get fire both a RoutedEvent and an AttachedEvent from "GrandChild" and have them handled in "MainWindow" two levels up - but I am now confused what's difference between the two? Except how they are declared in "GrandChild". I want to add that both use "RegisterRoutedEvent" but RoutedEvent has a CLR wrapper
 
References:
http://weblogs.asp.net/vblasberg/archive/2010/03/30/wpf-routed-events-bubbling-several-layers-up.aspx
http://chuckhays.net/blog/2010/05/21/very-simple-routed-event-example/comment-page-1/#comment-1021
http://en.csharp-online.net/WPF_Concepts%E2%80%94Routed_Events_in_Action
 
MainWindow - Top Level


<Label>Main Window</Label>



 
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
 
private void GrandChild_GrandChildRoutedEvClick(object sender, RoutedEventArgs e)
{
string Message = "MainWindow - GrandChildRoutedEvClickEvent handler - Source=" + Convert.ToString(e.Source);
MessageBox.Show(Message);
e.Handled = false;
return;
}
 
private void GrandChildAttachedEvClickHandler(object sender, RoutedEventArgs e)
{
string Message = "MainWindow - GrandChildAttachedEvClickHandler - Source=" + Convert.ToString(e.Source);
MessageBox.Show(Message);
return;
}
}
 
MiddleChild - 2nd Level


<Label>MiddleChild</Label>



 
public partial class MiddleChild : UserControl
{
public MiddleChild()
{
InitializeComponent();
}
 
private void GrandChild_GrandChildRoutedEvClick(object sender, RoutedEventArgs e)
{
string Message = "MiddleChild - GrandChildRoutedEvClickEvent handler - Source=" + Convert.ToString(e.Source);
MessageBox.Show(Message);
e.Handled = true; // set to true and MainWindow handler won't be triggered
return;
}
}
 
GrandChild - bottom level


<Label>GrandChild</Label>
<Button Name="btnGrandChild" Click="btnGrandChild_Click_1">Button from GrandChild</Button>


 
public partial class GrandChild : UserControl
{
#region Routed Event
public static readonly RoutedEvent GrandChildRoutedEvClickEvent = EventManager.RegisterRoutedEvent("GrandChildRoutedEvClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(GrandChild));
 
// Provide CLR accessors for the event
public event RoutedEventHandler GrandChildRoutedEvClick
{
add { AddHandler(GrandChildRoutedEvClickEvent, value); }
remove { RemoveHandler(GrandChildRoutedEvClickEvent, value); }
}
#endregion
 
#region Attached Event
public static readonly RoutedEvent GrandChildAttachedEvClickEvent =
EventManager.RegisterRoutedEvent("GrandChildAttachedEvClick",
RoutingStrategy.Bubble,
typeof(RoutedEventHandler),
typeof(GrandChild));
 
public static void AddGrandChildAttachedEvClickHandler(DependencyObject o, RoutedEventHandler handler)
{
((UIElement)o).AddHandler(GrandChild.GrandChildAttachedEvClickEvent, handler);
}
public static void RemoveGrandChildAttachedEvClickHandler(DependencyObject o, RoutedEventHandler handler)
{
((UIElement)o).RemoveHandler(GrandChild.GrandChildAttachedEvClickEvent, handler);
}
#endregion
 
public GrandChild()
{
InitializeComponent();
}
 
private void btnGrandChild_Click_1(object sender, RoutedEventArgs e)
{
this.RaiseEvent(new RoutedEventArgs(GrandChildRoutedEvClickEvent, this));
this.RaiseEvent(new RoutedEventArgs(GrandChildAttachedEvClickEvent, this));
return;
}
}
dev


modified 10-Jan-13 2:24am.

QuestionHow to play an Audio File After another has Finished in WPF MediaElement PinmemberVuyiswa Maseko4-Jan-13 3:58 
AnswerRe: How to play an Audio File After another has Finished in WPF MediaElement PinprotectorPete O'Hanlon4-Jan-13 4:13 
GeneralRe: How to play an Audio File After another has Finished in WPF MediaElement PinmemberVuyiswa Maseko4-Jan-13 6:08 
QuestionWPF tutorial book website pdf Pinmemberfrazzle-me1-Jan-13 10:44 
AnswerRe: WPF tutorial book website pdf PinmvpRichard MacCutchan1-Jan-13 22:31 
GeneralRe: WPF tutorial book website pdf Pinmemberfrazzle-me2-Jan-13 1:47 
GeneralRe: WPF tutorial book website pdf PinprotectorPete O'Hanlon2-Jan-13 5:48 
GeneralRe: WPF tutorial book website pdf PinmvpRichard MacCutchan2-Jan-13 6:09 
GeneralRe: WPF tutorial book website pdf PinprotectorPete O'Hanlon2-Jan-13 6:10 
AnswerRe: WPF tutorial book website pdf PinmvpAbhinav S2-Jan-13 2:21 
GeneralRe: WPF tutorial book website pdf Pinmemberfrazzle-me2-Jan-13 7:08 
AnswerRe: WPF tutorial book website pdf PinmemberFernando E. Braz2-Jan-13 5:15 
GeneralRe: WPF tutorial book website pdf Pinmemberfrazzle-me2-Jan-13 7:07 
QuestionWPF Tab Styling Question #2 PinmemberKevin Marois1-Jan-13 8:59 
AnswerRe: WPF Tab Styling Question #2 PinprotectorPete O'Hanlon1-Jan-13 9:48 
GeneralRe: WPF Tab Styling Question #2 PinmemberKevin Marois1-Jan-13 9:55 
GeneralRe: WPF Tab Styling Question #2 PinprotectorPete O'Hanlon1-Jan-13 9:56 
GeneralRe: WPF Tab Styling Question #2 PinmemberKevin Marois1-Jan-13 10:06 
GeneralRe: WPF Tab Styling Question #2 PinmentorWayne Gaylard1-Jan-13 23:00 
GeneralRe: WPF Tab Styling Question #2 PinprotectorPete O'Hanlon1-Jan-13 23:08 
GeneralRe: WPF Tab Styling Question #2 PinmemberKevin Marois2-Jan-13 15:41 
GeneralRe: WPF Tab Styling Question #2 PinprotectorPete O'Hanlon2-Jan-13 21:05 
GeneralRe: WPF Tab Styling Question #2 PinmemberKevin Marois2-Jan-13 21:40 
QuestionWPF TabItem Styling Question PinmemberKevin Marois30-Dec-12 11:16 
AnswerRe: WPF TabItem Styling Question PinprotectorPete O'Hanlon30-Dec-12 11:40 
GeneralRe: WPF TabItem Styling Question PinmemberKevin Marois30-Dec-12 15:16 
QuestionList Item Fore & Back Colors PinmemberKevin Marois29-Dec-12 7:52 
QuestionMVVM:How to bind the MenuItem Command of ListBoxItem ContextMenu dynamically? PinmemberMember 137073829-Dec-12 1:58 
AnswerRe: MVVM:How to bind the MenuItem Command of ListBoxItem ContextMenu dynamically? PinmemberSledgeHammer0129-Dec-12 7:22 
GeneralRe: MVVM:How to bind the MenuItem Command of ListBoxItem ContextMenu dynamically? PinmemberMember 137073829-Dec-12 15:44 
GeneralRe: MVVM:How to bind the MenuItem Command of ListBoxItem ContextMenu dynamically? PinmemberSledgeHammer0129-Dec-12 16:26 
GeneralRe: MVVM:How to bind the MenuItem Command of ListBoxItem ContextMenu dynamically? PinmemberMember 137073829-Dec-12 17:00 
GeneralRe: MVVM:How to bind the MenuItem Command of ListBoxItem ContextMenu dynamically? PinmemberSledgeHammer0129-Dec-12 17:25 
GeneralRe: MVVM:How to bind the MenuItem Command of ListBoxItem ContextMenu dynamically? PinmemberMember 137073829-Dec-12 19:02 
Questionmm PinmemberAishwarya aishu28-Dec-12 0:44 
AnswerRe: mm PinmvpRichard MacCutchan28-Dec-12 5:59 

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
Web04 | 2.8.140721.1 | Last Updated 25 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid