<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>maonet technotes &#187; WPF</title>
	<atom:link href="http://maonet.wordpress.com/category/wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://maonet.wordpress.com</link>
	<description>IOC(SM):MOC(RM):TDD(NU):SCC(TFS):ORM(L2S):JSL(Jq):CIS(CC)</description>
	<lastBuildDate>Thu, 31 Dec 2009 17:16:53 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='maonet.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/27569a47b055d3d0ff1d52cf3b0ce0d7?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>maonet technotes &#187; WPF</title>
		<link>http://maonet.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://maonet.wordpress.com/osd.xml" title="maonet technotes" />
		<item>
		<title>MEF in MVVM</title>
		<link>http://maonet.wordpress.com/2009/11/24/mef-in-mvvm-with-wcf/</link>
		<comments>http://maonet.wordpress.com/2009/11/24/mef-in-mvvm-with-wcf/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 18:24:24 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[IOC]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[MEF]]></category>
		<category><![CDATA[MVVM]]></category>

		<guid isPermaLink="false">http://maonet.wordpress.com/?p=818</guid>
		<description><![CDATA[I read a post about MEF vs. IOC which cleared the confusion: MEF should be used external of app, while IOC should be used internally.
Good point. I have been struggling with how to separate my view and view model correctly in WPF app for a long time.   In fact Bil Simer already suggested that MEF [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=818&subd=maonet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I read a post about <a href="http://mef.codeplex.com/">MEF</a> vs. IOC which cleared the confusion: MEF should be used external of app, while IOC should be used internally.</p>
<p>Good point. I have been struggling with how to separate my view and view model correctly in WPF app for a long time.   In fact Bil Simer already suggested that MEF is perfect fit in MVVM/Presentation Model last year during the Edmonton Code Camp 2008.</p>
<p>Ideally, all view models can be compiled into a separated assembly and put into specific folder to be imported by UI views!</p>
<p>Some code changes during my code conversion include:</p>
<ul>
<li>Remove ctor args from view model, I haven&#8217;t figure out how to feed ctor args when MEF importing. This is not easy as auto-wiring in IOC. I ended up with a separate initialize method in each view model, which is not too bad, because I have to call wireUpViewModel from view anyway, this Initialize method has a perfect place to put.</li>
<li>I&#8217;m still not sure where should I put Container.Compose() method, because this method needs the instance the object to be imported into, I think compose as needed is better for WPF app.</li>
<li>Shared mode is the default behavior for export and import, it messed up my event handling code, (true, I didn&#8217;t do -= before +=). I had to explicitly add this everywhere.</li>
<li><span style="text-decoration:line-through;">AllowRecomposition is a pain for me, couldn&#8217;t get it work at all. I have tried many different ways to create a second instance of the exported class. PartCreationPolicy? AllowRecomposition attribute? Maybe because I&#8217;m working on a beta version?</span>   Recomposition doesn&#8217;t work in contrustor paramteters, see <a href="http://blogs.msdn.com/gblock/archive/2009/03/21/recomposition-and-constructors.aspx">Glen&#8217;s post</a>.</li>
<li>Too many attributes kinds of pollute my code. Adding those export/import attributes just like playing ping-pong. If you are not good at it, you become dizzy very quickly.<br />
<blockquote>
<pre>[Export]
[PartCreationPolicy(CreationPolicy.NonShared)]

[Import(typeof(NewRequestTypeViewModel), RequiredCreationPolicy = CreationPolicy.NonShared)]

[ImportingConstructor]

[Import(AllowRecomposition=true)] //this can apply directly on ctor parameters, but recompositorion won't work in ctor (for now)</pre>
</blockquote>
</li>
<li>I still feel using StructureMap to hookup viewmodel inside view is better and more comfortable. Even this violates some principals,  but in shell to open the view is much simpler, just new view(). ViewModel should sit behind the view, those UI developers/designers shouldn&#8217;t be ware of the exist of any view modles.</li>
</ul>
<pre class="brush: csharp;">
public RequestDetailsView(RequestDto requestDto)
{
  InitializeComponent();
  _viewModel = ObjectFactory.With(&quot;requestDto&quot;).EqualTo(requestDto).GetInstance&lt;MyViewModel&gt;();
  DataContext = _viewModel;
}
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/818/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=818&subd=maonet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://maonet.wordpress.com/2009/11/24/mef-in-mvvm-with-wcf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>WPF ListView Control</title>
		<link>http://maonet.wordpress.com/2009/09/11/wpf-listview-control/</link>
		<comments>http://maonet.wordpress.com/2009/09/11/wpf-listview-control/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 21:14:48 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[ListView]]></category>

		<guid isPermaLink="false">http://maonet.wordpress.com/?p=741</guid>
		<description><![CDATA[We build framework, you build application.
This should be the motto for Microsoft, and any framework provider. But thing is different in WPF world, try google how many people are working so hard to make ListView header click sortable.
I don&#8217;t like code behind, the classic event hook up isn&#8217;t a clean solution at all. There are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=741&subd=maonet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>We build framework, you build application.</p>
<p>This should be the motto for Microsoft, and any framework provider. But thing is different in WPF world, try google how many people are working so hard to make ListView header click sortable.</p>
<p>I don&#8217;t like code behind, the classic event hook up isn&#8217;t a clean solution at all. There are a few smart guys using attached property to implement this sort feature, xaml can be much simpler, and we can slowly build our own WPF framewrok extension. (?)</p>
<p>The idea can be found from <a href="http://mbrownchicago.spaces.live.com/Blog/cns!2221DC39E0C749A4!331.entry">this post</a>, but the attached source code are missing, <a href="http://tomlev2.wordpress.com/2009/08/04/wpf-automatically-sort-a-gridview-continued/">this post</a> uses same technology with  full version of source code. In fact, I think Thomas&#8217; solution is better, he is using a technique called Adorner, which is cleaner than the other one using switching template. The only part I don&#8217;t like is the extra GridViewSort.PropertyName in his xmal to set the sorting property name. Why not just use the native binding name? like this:</p>
<blockquote><p>propertyName = ((System.Windows.Data.Binding)headerClicked.Column.DisplayMemberBinding).Path.Path;</p></blockquote>
<p>That&#8217;s for click-header-sorting.</p>
<p>How about double-click to trigger event/command in view model? Check <a href="http://sachabarber.net/?p=532">this post</a>.</p>
<p>Is there an open source project somewhere called WPF contrib? Yes, check out the WPF tool kit on codeplex, at least the click-header-sorting is supported, including some other fancy feature, such as the alternate row color.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/741/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=741&subd=maonet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://maonet.wordpress.com/2009/09/11/wpf-listview-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Rewrap Evil ValidationErrors in WPF ValidationRule to enable ajax like validation on WPF Form</title>
		<link>http://maonet.wordpress.com/2009/07/08/rewrap-evil-validationerrors-in-wpf-validationrule/</link>
		<comments>http://maonet.wordpress.com/2009/07/08/rewrap-evil-validationerrors-in-wpf-validationrule/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 19:28:16 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://maonet.wordpress.com/?p=690</guid>
		<description><![CDATA[We use Evil Attribute library in our service and UI/ViewModel to do validation on DTO, the big advantage is centralizing the validation rules. One challenge left is how to enable WPF Forms dynamically showing the error message, like ajax doing on web.
Found a very smart and simple solution for this, what we need to do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=690&subd=maonet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>We use <a href="http://evil.codeplex.com/Wiki/View.aspx?title=ValidateMinValue&amp;referringTitle=Home">Evil Attribute library</a> in our service and UI/ViewModel to do validation on DTO, the big advantage is centralizing the validation rules. One challenge left is how to enable WPF Forms dynamically showing the error message, like ajax doing on web.</p>
<p>Found <a href="http://weblogs.asp.net/monikadyrda/rss.aspx">a very smart and simple solution</a> for this, what we need to do is simply to wrap the Evil ValidationErrors in WPF ValidationRule class.</p>
<pre class="brush: xml;">
&lt;Window.Resources&gt;
 &lt;ControlTemplate x:Key=&quot;TextBoxErrorTemplate&quot;&gt;
 &lt;StackPanel&gt;
 &lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;
 &lt;Image Height=&quot;16&quot; Margin=&quot;0,0,5,0&quot;
 Source=&quot;warning_48.png&quot;/&gt;
 &lt;AdornedElementPlaceholder x:Name=&quot;Holder&quot;/&gt;
 &lt;/StackPanel&gt;
 &lt;Label Foreground=&quot;Red&quot; Content=&quot;{Binding ElementName=Holder,
 Path=AdornedElement.(Validation.Errors)[0].ErrorContent}&quot;/&gt;
 &lt;/StackPanel&gt;
 &lt;/ControlTemplate&gt;
 &lt;/Window.Resources&gt;
 &lt;Grid&gt;
    ...

  &lt;TextBox Height=&quot;23&quot; Margin=&quot;35,9,77,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot;
     KeyUp=&quot;OnTextBoxKeyUp&quot;
     Validation.ErrorTemplate=&quot;{StaticResource TextBoxErrorTemplate}&quot;&gt;
     &lt;TextBox.Text&gt;
    &lt;Binding ElementName=&quot;listBox1&quot; Path=&quot;SelectedItem&quot; UpdateSourceTrigger=&quot;PropertyChanged&quot;&gt;
      &lt;Binding.ValidationRules&gt;
        &lt;ViewModels:EmailRoleRule /&gt;
      &lt;/Binding.ValidationRules&gt;
    &lt;/Binding&gt;
  &lt;/TextBox.Text&gt;
 &lt;/TextBox&gt;
</pre>
<pre class="brush: csharp;">

public class EmailRoleRule : ValidationRule
 {
  public override ValidationResult Validate(object value, CultureInfo cultureInfo)
   {
   var roleName = (string) value;
   var validator = new EvilValidator(new EmailRoleDto() { Name = roleName });
   if (validator.IsValid())
   {
    return new ValidationResult(true, null);
   }
   return new ValidationResult(false, string.Join(&quot;\n&quot;, validator.ValidationErrors.ToArray()));
  }
 }
</pre>
<p><img class="aligncenter size-full wp-image-693" title="wpf_validation" src="http://maonet.files.wordpress.com/2009/07/wpf_validation.jpg?w=281&#038;h=88" alt="wpf_validation" width="281" height="88" /></p>
<p>This technoque is actually described on <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.validation.errortemplate.aspx">MSDN</a>.</p>
<p>Here is <a href="http://karlshifflett.wordpress.com/2008/04/03/wpf-sample-series-handling-and-reporting-wpf-data-binding-validation-errors-and-exceptions/">a post</a> talking about the same skill but takes advantage of tooltips, pretty close to CSLA content control.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/690/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/690/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/690/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/690/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/690/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/690/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/690/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/690/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/690/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/690/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=690&subd=maonet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://maonet.wordpress.com/2009/07/08/rewrap-evil-validationerrors-in-wpf-validationrule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>

		<media:content url="http://maonet.files.wordpress.com/2009/07/wpf_validation.jpg" medium="image">
			<media:title type="html">wpf_validation</media:title>
		</media:content>
	</item>
		<item>
		<title>Twoway databinding selectedItem in WPF listbox</title>
		<link>http://maonet.wordpress.com/2009/07/02/twoway-databinding-selecteditem-in-wpf-listbox/</link>
		<comments>http://maonet.wordpress.com/2009/07/02/twoway-databinding-selecteditem-in-wpf-listbox/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 20:49:15 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[MVVM]]></category>

		<guid isPermaLink="false">http://maonet.wordpress.com/?p=676</guid>
		<description><![CDATA[Found this neat feature from Jonas&#8217; ppt. What a great feature from WPF data-binding! See page 18.

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=676&subd=maonet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Found this neat feature from Jonas&#8217; ppt. What a great feature from WPF data-binding! See page 18.</p>
<p><object type='application/x-shockwave-flash' wmode='transparent' data='http://static.slideshare.net/swf/ssplayer2.swf?id=1664018&#038;doc=mvvmpresentationndc2009-090630160910-phpapp02' width='600' height='492'><param name='movie' value='http://static.slideshare.net/swf/ssplayer2.swf?id=1664018&#038;doc=mvvmpresentationndc2009-090630160910-phpapp02' /><param name='allowFullScreen' value='true' /><param name='allowScriptAccess' value='always' /></object></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/676/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/676/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/676/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/676/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/676/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/676/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/676/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/676/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/676/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/676/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=676&subd=maonet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://maonet.wordpress.com/2009/07/02/twoway-databinding-selecteditem-in-wpf-listbox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Control the entry point of WPF application</title>
		<link>http://maonet.wordpress.com/2009/05/07/control-the-entry-point-of-wpf-application/</link>
		<comments>http://maonet.wordpress.com/2009/05/07/control-the-entry-point-of-wpf-application/#comments</comments>
		<pubDate>Thu, 07 May 2009 15:05:18 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[StructureMap]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://maonet.wordpress.com/?p=590</guid>
		<description><![CDATA[The app.main() is gone in default auto-gened WPF application, there are some workarounds to add customized startup app class. I found adding Startup attribute then implement startup eventhandler is a eaiser and clean solution:
Adding Startup property to App.xaml:

&#60;Application x:Class=&#8221;StakeholderDemo.Layers.WpfUI.App&#8221;
xmlns=&#8221;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8220;
xmlns:x=&#8221;http://schemas.microsoft.com/winfx/2006/xaml&#8220;
Startup=&#8221;App_StartUp&#8221;
StartupUri=&#8221;MenuForm.xaml&#8221;
&#62;
&#60;Application.Resources&#62;
&#60;/Application.Resources&#62;
&#60;/Application&#62;

Implement code:

public partial class App : Application
{
void  App_StartUp(object sender, StartupEventArgs e)
{
ObjectFactory.Initialize(x =&#62;  x.AddRegistry&#60;WpfClientDependencyRegistry&#62;());
}

   [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=590&subd=maonet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The app.main() is gone in default auto-gened WPF application, there are <a href="http://www.infosysblogs.com/microsoft/2008/09/how_to_write_custom_main_metho.html">some workarounds</a> to add customized startup app class. I found adding Startup attribute then implement startup eventhandler is a eaiser and clean solution:</p>
<div>Adding Startup property to App.xaml:</div>
<blockquote>
<div>&lt;Application x:Class=&#8221;StakeholderDemo.Layers.WpfUI.App&#8221;<br />
xmlns=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>&#8220;<br />
xmlns:x=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>&#8220;<br />
<span style="color:#ff0000;">Startup=&#8221;App_StartUp&#8221;</span><br />
StartupUri=&#8221;MenuForm.xaml&#8221;<br />
&gt;<br />
&lt;Application.Resources&gt;</p>
<p>&lt;/Application.Resources&gt;<br />
&lt;/Application&gt;</p></div>
</blockquote>
<div>Implement code:</div>
<blockquote>
<div>public partial class App : Application<br />
{</p>
<p>void  App_StartUp(object sender, StartupEventArgs e)<br />
{<br />
ObjectFactory.Initialize(x =&gt;  x.AddRegistry&lt;WpfClientDependencyRegistry&gt;());<br />
}</p></div>
</blockquote>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/590/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=590&subd=maonet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://maonet.wordpress.com/2009/05/07/control-the-entry-point-of-wpf-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Handle/Display UnhandleException in WPF</title>
		<link>http://maonet.wordpress.com/2009/04/23/handledisplay-unhandleexception-in-wpf/</link>
		<comments>http://maonet.wordpress.com/2009/04/23/handledisplay-unhandleexception-in-wpf/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 18:02:27 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[exception]]></category>

		<guid isPermaLink="false">http://maonet.wordpress.com/?p=565</guid>
		<description><![CDATA[From MSDN， unhandledExcpetion can be handled genereally in application.xaml,
&#60;Application
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.App"
  StartupUri="MainWindow.xaml"
  DispatcherUnhandledException="App_DispatcherUnhandledException" /&#62;

using System.Windows; // Application
using System.Windows.Threading; // DispatcherUnhandledExceptionEventArgs

namespace SDKSample
{
    public partial class App : Application
    {
        void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
    [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=565&subd=maonet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>From <a href="http://msdn.microsoft.com/en-us/library/ms743714.aspx#Unhandled_Exceptions"><span><span>MSDN</span></span></a><span>， unhandledExcpetion can be handled <span>genereally</span> in application.<span>xaml</span>,</span></p>
<pre class="libCScode" style="white-space:pre-wrap;">&lt;Application
<span>  <span>xmlns</span>=</span><span style="color:maroon;"><span>"<span>http</span>://<span>schemas</span>.<span>microsoft</span>.com/<span>winfx</span>/2006/<span>xaml</span>/presentation"</span></span>
  xmlns:x=<span style="color:maroon;"><span>"<span>http</span>://<span>schemas</span>.<span>microsoft</span>.com/<span>winfx</span>/2006/<span>xaml</span>"</span></span>
  x:Class=<span style="color:maroon;"><span>"<span>SDKSample</span>.App"</span></span>
<span>  <span>StartupUri</span>=</span><span style="color:maroon;"><span>"<span>MainWindow</span>.<span>xaml</span>"</span></span>
  DispatcherUnhandledException=<span style="color:maroon;">"App_DispatcherUnhandledException"</span> /&gt;

<span style="color:blue;">using</span> System.Windows; // Application
<span style="color:blue;">using</span> System.Windows.Threading; // DispatcherUnhandledExceptionEventArgs

<span style="color:blue;"><span><span>namespace</span></span></span><span> <span>SDKSample</span></span>
{
    <span style="color:blue;">public</span> partial <span style="color:blue;">class</span> App : Application
    {
        <span style="color:blue;">void</span> App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            <span style="color:green;"><span>// Process <span>unhandled</span> exception</span></span>

...

            <span style="color:green;"><span>// Prevent default <span>unhandled</span> exception processing</span></span>
            e.Handled = <span style="color:blue;">true</span>;
        }
    }
}</pre>
<p><span>I like this very much, but suggestion from <span>IglooCoder</span> is, you don&#8217;t want set Handled=true, the UnHandleException should keep unhanded in this UnhandledException event, for specific exception you want to handle, do it on screen or somewhere else, like local WcfProxy. This event </span><span>should be the place you want to <strong>display</strong> error or log or send screen shot to admin. Anyway, <span>exception</span>s shouldn&#8217;t be<strong> handled</strong> here.</span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/565/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=maonet.wordpress.com&blog=431779&post=565&subd=maonet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://maonet.wordpress.com/2009/04/23/handledisplay-unhandleexception-in-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
	</channel>
</rss>