<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Reference &#187; Routed Events</title>
	<atom:link href="http://sullivan.net/blog/tag/routed-events/feed/" rel="self" type="application/rss+xml" />
	<link>http://sullivan.net/blog</link>
	<description>A collection of code for my reference (and perhaps other people too)</description>
	<lastBuildDate>Wed, 25 Jan 2012 17:53:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Routed Events &#8211; Bubbling</title>
		<link>http://sullivan.net/blog/2009/07/routed-events-quick-and-simple-bubbling/</link>
		<comments>http://sullivan.net/blog/2009/07/routed-events-quick-and-simple-bubbling/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 12:20:23 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[Routed Events]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://sullivan.net/blog/?p=38</guid>
		<description><![CDATA[Because I sometimes forget the syntax, a have here a quick bubbling routed event for WPF: For you have to register the event. Then you have to create the poperty that adds and removed the handlers. // Register the event public static readonly RoutedEvent CloseEvent = EventManager.RegisterRoutedEvent(&#34;Close&#34;, RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(CustomPopupControl)); // Provide CLR accessors for [...]]]></description>
			<content:encoded><![CDATA[<p>Because I sometimes forget the syntax, a have here a quick bubbling routed event for WPF:</p>
<p>For you have to register the event. Then you have to create the poperty that adds and removed the handlers.</p>
<pre class="brush: c#">
// Register the event
public static readonly RoutedEvent CloseEvent =
    EventManager.RegisterRoutedEvent(&quot;Close&quot;, RoutingStrategy.Bubble, typeof(RoutedEventHandler),
    typeof(CustomPopupControl));

// Provide CLR accessors for the event
public event RoutedEventHandler Close
{
    add { AddHandler(CloseEvent, value); }
    remove { RemoveHandler(CloseEvent, value); }
}
</pre>
<p>To manualy raise the event:</p>
<pre class="brush: c#">
RoutedEventArgs args = new RoutedEventArgs(CloseEvent);
RaiseEvent(args);
</pre>
<p>To listen for the event:</p>
<pre class="brush: c#">
CustomPopupControl popup = new CustomerPopupControl();
popup.Close += new RoutedEventHandler(popup_Closed);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sullivan.net/blog/2009/07/routed-events-quick-and-simple-bubbling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

