<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Thomas Lebrun</title><link>http://weblogs.asp.net/thomaslebrun/default.aspx</link><description>All you need about WPF, Silverlight &amp; LINQ !</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>[Windows Seven] How to use biometric authentication in your .NET applications ?</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/08/19/windows-seven-how-to-use-biometric-authentication-in-your-net-applications.aspx</link><pubDate>Wed, 19 Aug 2009 09:08:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7172281</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>3</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/08/19/windows-seven-how-to-use-biometric-authentication-in-your-net-applications.aspx#comments</comments><description>&lt;P&gt;Currently, most of the laptops have a lot of features (SmartCard reader, etc.) that are not used.&lt;/P&gt;
&lt;P&gt;But, with &lt;EM&gt;Windows Seven&lt;/EM&gt;, one of this feature appears more useful: &lt;STRONG&gt;biometric authentication&lt;/STRONG&gt;. Indeed, for the moment, this authentication must be done with tiers softwares, developed by constructors.&lt;/P&gt;
&lt;P&gt;But now, Windows Seven get a &lt;A href="http://msdn.microsoft.com/en-us/library/dd401509(VS.85).aspx"&gt;&lt;FONT color=#006ff7&gt;new API&lt;/FONT&gt;&lt;/A&gt; allowing the programmation/manipulation of biometric readers. So it's now possible, by playing with some PInvoke, to create a wrapper for the API.&lt;/P&gt;
&lt;P&gt;To help you, I've managed to create this wrapper. For now, only the method &lt;STRONG&gt;WinBioIdentifyWithCallback&lt;/STRONG&gt; is implemented but it should be quite easy to implement other. This method allows to check, asynchronously, that the user who have swipe his finger on the sensor is effectively a know user:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; WIDTH: 548px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 101px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://blogs.developpeur.org/blogs/tom/image_47685EC2.png" width=548 height=101 mce_src="http://blogs.developpeur.org/blogs/tom/image_47685EC2.png"&gt;&lt;A href="file:///C:/Users/Tom/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles384AE41E/image[15].png"&gt;&lt;/P&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; WIDTH: 548px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 101px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://blogs.developpeur.org/blogs/tom/image_4A2E13B5.png" width=530 height=92 mce_src="http://blogs.developpeur.org/blogs/tom/image_4A2E13B5.png"&gt;&lt;/A&gt; 
&lt;P&gt;In case of the user is unknow, the application receive an event which indicate the problem:&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/Tom/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles384AE41E/image[12].png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; WIDTH: 371px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 73px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://blogs.developpeur.org/blogs/tom/image_76D6CD8E.png" width=339 height=60 mce_src="http://blogs.developpeur.org/blogs/tom/image_76D6CD8E.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use it, it's quite simple:&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/Tom/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles384AE41E/image[19].png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; WIDTH: 539px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 296px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.developpeur.org/blogs/tom/image_55E35AE7.png" width=539 height=296 mce_src="http://blogs.developpeur.org/blogs/tom/image_55E35AE7.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;It's important to note that this wrapper is composed by 3 DLLs:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Biometric.Wrapper.dll&lt;/STRONG&gt;: It's the managed DLL calling the unmanaged methods&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Interop.WinBio.dll&lt;/STRONG&gt;: This DLL contains the definition of the unmanaged methods (PInvoke). Instead of creating this DLL by hand, I've prefered to generate it by using the tool &lt;A href="http://www.pinvoker.com/"&gt;&lt;STRONG&gt;&lt;FONT color=#006ff7&gt;PInvoker&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;. It's quick, workfs fine and, in case of any issue, tool's creator is really active so don't hesitate to give it a try !&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;PInvoker.Marshal.dll&lt;/STRONG&gt;: DLL generated by the tool PInvoker and which contains the definition of thetypes that are used in Interop.WinBio.dll&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;To give a try to this, just follow this link&amp;nbsp;: &lt;A title=http://morpheus.developpez.com/blog/BiometricWrapper/BiometricWrapper.zip href="http://morpheus.developpez.com/blog/BiometricWrapper/BiometricWrapper.zip"&gt;&lt;FONT color=#006ff7&gt;http://morpheus.developpez.com/blog/BiometricWrapper/BiometricWrapper.zip&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#006ff7&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#006ff7&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have fun !&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bye&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7172281" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Seven/default.aspx">Seven</category></item><item><title>[WPF / MVVM] How to get data in “design time” ?</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/05/04/wpf-mvvm-how-to-get-data-in-design-time.aspx</link><pubDate>Mon, 04 May 2009 02:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7071130</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>2</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/05/04/wpf-mvvm-how-to-get-data-in-design-time.aspx#comments</comments><description>&lt;p&gt;When you are working with &lt;strong&gt;WPF&lt;/strong&gt; and &lt;strong&gt;MVVM &lt;strong&gt;Pattern&lt;/strong&gt;&lt;/strong&gt;, you can regret that the designer doesn’t get data, in design time, that allow him to simply modified the graphical interface.&lt;/p&gt;  &lt;p&gt;To help my developments, I’ve created a little attached property which will create an instance of the type passed in parameter:&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red128\green128\blue128;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 \cf1 public\cf0  \cf1 static\cf0  \cf1 class\cf0  \cf4 DesignTimeHelper\par ??\cf0     \{\par ??        \cf5 ///\cf6  \cf5 &amp;lt;summary&amp;gt;\par ??\cf0         \cf5 ///\cf6  DependencyProperty used to store the DesignTime property.\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf1 public\cf0  \cf1 static\cf0  \cf1 readonly\cf0  \cf4 DependencyProperty\cf0  DesignTimeDataProperty =\par ??            \cf4 DependencyProperty\cf0 .RegisterAttached(\cf7 "DesignTimeData"\cf0 , \cf1 typeof\cf0 (\cf4 Type\cf0 ), \cf1 typeof\cf0 (\cf4 DesignTimeHelper\cf0 ), \cf1 new\cf0  \cf4 FrameworkPropertyMetadata\cf0 (\cf1 null\cf0 , \cf1 new\cf0  \cf4 PropertyChangedCallback\cf0 (OnDesignTimeDataChanged)));\par ??\par ??        \cf5 ///\cf6  \cf5 &amp;lt;summary&amp;gt;\par ??\cf0         \cf5 ///\cf6  Gets the design time data.\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;param name="obj"&amp;gt;\cf6 The obj.\cf5 &amp;lt;/param&amp;gt;\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;\par ??\cf0         \cf1 public\cf0  \cf1 static\cf0  \cf4 Type\cf0  GetDesignTimeData(\cf4 DependencyObject\cf0  obj)\par ??        \{\par ??            \cf1 return\cf0  (\cf4 Type\cf0 )obj.GetValue(DesignTimeDataProperty);\par ??        \}\par ??\par ??        \cf5 ///\cf6  \cf5 &amp;lt;summary&amp;gt;\par ??\cf0         \cf5 ///\cf6  Sets the design time data.\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;param name="obj"&amp;gt;\cf6 The obj.\cf5 &amp;lt;/param&amp;gt;\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;param name="value"&amp;gt;\cf6 The value.\cf5 &amp;lt;/param&amp;gt;\par ??\cf0         \cf1 public\cf0  \cf1 static\cf0  \cf1 void\cf0  SetDesignTimeData(\cf4 DependencyObject\cf0  obj, \cf4 Type\cf0  value)\par ??        \{\par ??            obj.SetValue(DesignTimeDataProperty, value);\par ??        \}\par ??\par ??        \cf5 ///\cf6  \cf5 &amp;lt;summary&amp;gt;\par ??\cf0         \cf5 ///\cf6  Called when DesignTimeData changed.\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;param name="d"&amp;gt;\cf6 The source object.\cf5 &amp;lt;/param&amp;gt;\par ??\cf0         \cf5 ///\cf6  \cf5 &amp;lt;param name="e"&amp;gt;\cf6 The \cf5 &amp;lt;see cref="System.Windows.DependencyPropertyChangedEventArgs"/&amp;gt;\cf6  instance containing the event data.\cf5 &amp;lt;/param&amp;gt;\par ??\cf0         \cf1 private\cf0  \cf1 static\cf0  \cf1 void\cf0  OnDesignTimeDataChanged(\cf4 DependencyObject\cf0  d, \cf4 DependencyPropertyChangedEventArgs\cf0  e)\par ??        \{\par ??            \cf1 var\cf0  isOnDesignMode = \cf4 DesignerProperties\cf0 .GetIsInDesignMode(\cf1 new\cf0  \cf4 DependencyObject\cf0 ());\par ??            \cf1 if\cf0  (isOnDesignMode)\par ??            \{\par ??                \cf1 var\cf0  element = d \cf1 as\cf0  \cf4 FrameworkElement\cf0 ;\par ??                \cf1 if\cf0  (element == \cf1 null\cf0 )\par ??                    \cf1 throw\cf0  \cf1 new\cf0  \cf4 NullReferenceException\cf0 (\cf7 "element must not be null and must be an UIElement."\cf0 );\par ??\par ??                \cf1 var\cf0  designTimeDataType = e.NewValue \cf1 as\cf0  \cf4 Type\cf0 ;\par ??                \cf1 if\cf0  (designTimeDataType == \cf1 null\cf0 )\par ??                    \cf1 throw\cf0  \cf1 new\cf0  \cf4 NullReferenceException\cf0 (\cf7 "designTimeDataType must not be null."\cf0 );\par ??\par ??                element.DataContext = \cf4 Activator\cf0 .CreateInstance(designTimeDataType);\par ??            \}\par ??        \}\par ??    \}}
--&gt;&lt;/p&gt;  &lt;div style="font-family: courier new; background: white; color: black; font-size: 10pt"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DesignTimeHelper&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;{&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; DependencyProperty used to store the DesignTime property.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;readonly&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DependencyProperty&lt;/span&gt; DesignTimeDataProperty =&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;DependencyProperty&lt;/span&gt;.RegisterAttached(&lt;span style="color: #a31515"&gt;&amp;quot;DesignTimeData&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;DesignTimeHelper&lt;/span&gt;), &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;FrameworkPropertyMetadata&lt;/span&gt;(&lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;PropertyChangedCallback&lt;/span&gt;(OnDesignTimeDataChanged)));&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; Gets the design time data.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;obj&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The obj.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt; GetDesignTimeData(&lt;span style="color: #2b91af"&gt;DependencyObject&lt;/span&gt; obj)&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;)obj.GetValue(DesignTimeDataProperty);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; Sets the design time data.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;obj&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The obj.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The value.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; SetDesignTimeData(&lt;span style="color: #2b91af"&gt;DependencyObject&lt;/span&gt; obj, &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt; value)&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; obj.SetValue(DesignTimeDataProperty, value);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; Called when DesignTimeData changed.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;d&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The source object.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;see cref=&amp;quot;System.Windows.DependencyPropertyChangedEventArgs&amp;quot;/&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt; instance containing the event data.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; OnDesignTimeDataChanged(&lt;span style="color: #2b91af"&gt;DependencyObject&lt;/span&gt; d, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs&lt;/span&gt; e)&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;var&lt;/span&gt; isOnDesignMode = &lt;span style="color: #2b91af"&gt;DesignerProperties&lt;/span&gt;.GetIsInDesignMode(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DependencyObject&lt;/span&gt;());&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (isOnDesignMode)&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;var&lt;/span&gt; element = d &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;FrameworkElement&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (element == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;NullReferenceException&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;element must not be null and must be an UIElement.&amp;quot;&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;var&lt;/span&gt; designTimeDataType = e.NewValue &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (designTimeDataType == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;NullReferenceException&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;designTimeDataType must not be null.&amp;quot;&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; element.DataContext = &lt;span style="color: #2b91af"&gt;Activator&lt;/span&gt;.CreateInstance(designTimeDataType);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;}&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;To use this attached property, it’s simple: just create 2 ViewModels (one used for the data in “runtime” and the second one used for the data in “designtime”):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/thomaslebrun/image_1D1536CF.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_429EB430.png" width="244" height="223" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Then, use the property:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/thomaslebrun/image_19B39F27.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_1F8E42C0.png" width="504" height="54" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At “design time”, we can see that data are really different from “runtime”:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/thomaslebrun/image_2C1BEFDC.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_5060D45E.png" width="264" height="147" /&gt;&lt;/a&gt; &lt;a href="http://weblogs.asp.net/blogs/thomaslebrun/image_60F8CF4C.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_0C5CF047.png" width="265" height="141" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/thomaslebrun/image_63DE0E32.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_149115DE.png" width="316" height="223" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;For your information, here is the content of the ViewModel in “design” mode:&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf1 namespace\cf0  TestToolbox.ViewModels.Design\par ??\{\par ??    \cf1 class\cf0  \cf4 SampleViewModel\cf0  : \cf4 ISampleViewModel\par ??\cf0     \{\par ??\cf1         #region\cf0  ISampleViewModel Members\par ??\par ??        \cf1 public\cf0  \cf1 string\cf0  Text\par ??        \{\par ??            \cf1 get\cf0  \{ \cf1 return\cf0  \cf5 "Design time text"\cf0 ; \}\par ??        \}\par ??\par ??        \cf1 public\cf0  \cf1 string\cf0  Title\par ??        \{\par ??            \cf1 get\cf0  \{ \cf1 return\cf0  \cf5 "Design time title"\cf0 ; \}\par ??        \}\par ??\par ??\cf1         #endregion\par ??\cf0     \}\par ??\}}
--&gt;&lt;/p&gt;  &lt;div style="font-family: courier new; background: white; color: black; font-size: 10pt"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;namespace&lt;/span&gt; TestToolbox.ViewModels.Design&lt;/p&gt;    &lt;p style="margin: 0px"&gt;{&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SampleViewModel&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ISampleViewModel&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region&lt;/span&gt; ISampleViewModel Members&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; Text&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: #a31515"&gt;&amp;quot;Design time text&amp;quot;&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; Title&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: #a31515"&gt;&amp;quot;Design time title&amp;quot;&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;}&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;And here is the ViewModel for “runtime” mode:&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf1 namespace\cf0  TestToolbox.ViewModels\par ??\{\par ??    \cf1 public\cf0  \cf1 class\cf0  \cf4 SampleViewModel\cf0  : \cf4 ISampleViewModel\par ??\cf0     \{\par ??\cf1         #region\cf0  ISampleViewModel Members\par ??\par ??        \cf1 public\cf0  \cf1 string\cf0  Text\par ??        \{\par ??            \cf1 get\cf0  \{ \cf1 return\cf0  \cf5 "Runtime text"\cf0 ; \}\par ??        \}\par ??\par ??        \cf1 public\cf0  \cf1 string\cf0  Title\par ??        \{\par ??            \cf1 get\cf0  \{ \cf1 return\cf0  \cf5 "Runtime title"\cf0 ; \}\par ??        \}\par ??\par ??\cf1         #endregion\par ??\cf0     \}\par ??\}}
--&gt;&lt;/p&gt;  &lt;div style="font-family: courier new; background: white; color: black; font-size: 10pt"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;namespace&lt;/span&gt; TestToolbox.ViewModels&lt;/p&gt;    &lt;p style="margin: 0px"&gt;{&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SampleViewModel&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ISampleViewModel&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region&lt;/span&gt; ISampleViewModel Members&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; Text&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: #a31515"&gt;&amp;quot;Runtime text&amp;quot;&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; Title&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: #a31515"&gt;&amp;quot;Runtime title&amp;quot;&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;}&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;That’s all ! Now, your designer is able to work with (sample) data that allow him to design the graphical interface of your application without having to launch it for testing/viewing the results.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Bye !&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;PS: Thanks to &lt;a href="http://www.simonferquel.net/blog/"&gt;Simon&lt;/a&gt; for the suggestion of using a type instead of a simple string [;)]&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7071130" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/MVVM/default.aspx">MVVM</category></item><item><title>[WPF] An addin to quickly generate your business objects compatible with WPF !</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/04/07/wpf-an-addin-to-quickly-generate-your-business-objects-compatible-with-wpf.aspx</link><pubDate>Tue, 07 Apr 2009 01:05:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7024482</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>2</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/04/07/wpf-an-addin-to-quickly-generate-your-business-objects-compatible-with-wpf.aspx#comments</comments><description>&lt;P&gt;When I work on projects, I often need to create business objects (Customer, Country, etc.) and I would like to be able to done this step very quickly.&lt;/P&gt;
&lt;P&gt;So I’ve created a little addin to Visual Studio 2008 that allow me to easily create my business objects/entities. This a an old project that I’ve decided to release even if I plan to re-write it because I think it could be an useful in addition to the &lt;A class="" title="XAML PowerToys" href="http://karlshifflett.wordpress.com/xaml-power-toys/" mce_href="http://karlshifflett.wordpress.com/xaml-power-toys/"&gt;XAML PowerToys&lt;/A&gt; developed by &lt;A class="" title="Karl Shifflett" href="http://karlshifflett.wordpress.com/" mce_href="http://karlshifflett.wordpress.com/"&gt;Karl Shifflett&lt;/A&gt;.&amp;nbsp;To use it, just right click on a project and select “&lt;EM&gt;Add Business Object&lt;/EM&gt;” under “&lt;EM&gt;VS PowerTools&lt;/EM&gt;”:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_5D9B9AD1.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_5D9B9AD1.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=119 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_6F2B859C.png" width=443 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_6F2B859C.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Once this is done, a little window is displayed and you can specify the name of your entities, if you want to mark it as serializable (using the &lt;STRONG&gt;DataContract&lt;/STRONG&gt;/&lt;STRONG&gt;DataMember&lt;/STRONG&gt; attributes) and the number of properties:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_385E04CB.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_385E04CB.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=216 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_0268E9E4.png" width=427 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_0268E9E4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have entered the number of properties you want on your entities, just press the TAB key to see an interface that allow you to write the name and the type of the properties:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_7CEA5372.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_7CEA5372.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=287 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_269DA899.png" width=412 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_269DA899.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;When you’re done, simply click the “OK” button to launch the create of the entity. Using &lt;STRONG&gt;CodeDOM&lt;/STRONG&gt;, the addin performs the following tasks:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Add the references and “&lt;STRONG&gt;using&lt;/STRONG&gt;” necessary&lt;/LI&gt;
&lt;LI&gt;Create a partial class corresponding to the entity you have entered the name. This class implements &lt;STRONG&gt;INotifyPropertyChanged&lt;/STRONG&gt; and &lt;STRONG&gt;INotifyPropertyChanging&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Create the partial methods corresponding to the properties defined in your class&lt;/LI&gt;
&lt;LI&gt;Define a collection for your class. The collection is simply a &lt;STRONG&gt;ObservableCollection&lt;/STRONG&gt; of the type you’ve just created&lt;/LI&gt;
&lt;LI&gt;Etc..&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_53EF189C.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_53EF189C.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=283 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_6A814116.png" width=486 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_6A814116.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;To install the addin, simply copy the file VSPowerTools.dll and VSPowerTools.AddIn to the Addins directory of Visual Studio 2008 (by default, it’s C:\Users\Username\Documents\Visual Studio 2008\Addins)&lt;/P&gt;
&lt;P&gt;Here is a list of the thing that I’m planned to do for this addin:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use M-V-VM pattern for the WPF part&lt;/LI&gt;
&lt;LI&gt;Allow user to select if he want C# or VB.NET generated code&lt;/LI&gt;
&lt;LI&gt;Manage the “Add Reference” part to support Silverlight (currently, the addin adds, as reference, the assemblies for the .NET Framework only, not Silverlight)&lt;/LI&gt;
&lt;LI&gt;Maybe use a package instead of a simple addin&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Here is the link to download the addin: &lt;A href="http://morpheus.developpez.com/wpf/tools/addins/VSPowerTools1.0.zip" mce_href="http://morpheus.developpez.com/wpf/tools/addins/VSPowerTools1.0.zip"&gt;http://morpheus.developpez.com/wpf/tools/addins/VSPowerTools1.0.zip&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you have any ideas or comments about this addin, feel free to &lt;A href="http://weblogs.asp.net/thomaslebrun/contact.aspx" target=_blank mce_href="http://weblogs.asp.net/thomaslebrun/contact.aspx"&gt;contact me&lt;/A&gt; or to post a comment !&lt;/P&gt;
&lt;P&gt;Happy coding !&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7024482" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Addins/default.aspx">Addins</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>[Silverlight 3] SaveFileDialog and the exception IOException: “The directory name is invalid”</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/04/01/silverlight-3-savefiledialog-and-the-exception-ioexception-the-directory-name-is-invalid.aspx</link><pubDate>Wed, 01 Apr 2009 10:09:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7019418</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>0</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/04/01/silverlight-3-savefiledialog-and-the-exception-ioexception-the-directory-name-is-invalid.aspx#comments</comments><description>&lt;p&gt;I encountered a bug when I tried to use the control SaveFileDialog, available in Silverlight 3. Indeed, every time I used the method &lt;strong&gt;OpenFile&lt;/strong&gt;, I received the following exception:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;IOException: The directory name is invalid&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;At first, I tought it was an issue with the permissions on the location where I tried to save the file but, after posting a &lt;a href="http://silverlight.net/forums/t/84656.aspx" target="_blank"&gt;message&lt;/a&gt; on the Silverlight’s forums, it’s appears the issue come from the Protected Mode that was activated, in Internet Explorer, for the Local Intranet Zone: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&amp;quot;IE -&amp;gt; Tools -&amp;gt; Internet Options -&amp;gt; Security –&amp;gt; Enable/Disable Protected Mode&amp;quot;&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As soon as I deactivate the protected mode, the call to the method OpenFile worked fine ! Of course, it’s a temporary fix because it’s not recommanded to keep the protected mode deactivated.&lt;/p&gt;  &lt;p&gt;Happy coding !&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Bye&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7019418" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category></item><item><title>[WPF] How to bind a control to a property defined in the Settings ?</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/03/26/wpf-how-to-bind-a-control-to-a-property-defined-in-the-settings.aspx</link><pubDate>Thu, 26 Mar 2009 08:23:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6971899</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>0</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/03/26/wpf-how-to-bind-a-control-to-a-property-defined-in-the-settings.aspx#comments</comments><description>&lt;p&gt;Settings are a very powerful feature of .NET applications that allows developers to store some values in the settings of the application:&lt;/p&gt;  &lt;p&gt;&lt;img height="134" src="http://morpheus.developpez.com/images/blog/WPFCommentselierunepropritdfiniedansless_89D9/image.png" width="517" /&gt; &lt;/p&gt;  &lt;p&gt;If you want to know how to bind a control to a property defined in the settings, it’s pretty simple. First, you need to add a custom XML namespace that will design the namespace where the settings are defined:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red163\green21\blue21;}??\fs20 xmlns:properties=\cf3 "clr-namespace:TestSettings.Properties"}
--&gt;&lt;/p&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: consolas"&gt;   &lt;p style="margin: 0px"&gt;xmlns:properties=&lt;span style="color: #a31515"&gt;&amp;quot;clr-namespace:TestSettings.Properties&amp;quot;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Then, in your XAML file, access the property using the following syntax:&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;}??\fs20 x:Static properties:Settings.Default}
--&gt;&lt;/p&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: consolas"&gt;   &lt;p style="margin: 0px"&gt;x:Static properties:Settings.Default&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;So here is the final result code:&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20         &amp;lt;\cf3 ListBox\cf0  x:Name=\cf4 "lb"\par ??\cf0                  ItemsSource=\cf4 "\{Binding Source=\{x:Static properties:Settings.Default\}, Path=Names\}"\cf0  /&amp;gt;}
--&gt;&lt;/p&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: consolas"&gt;   &lt;p style="margin: 0px"&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ListBox&lt;/span&gt; x:Name=&lt;span style="color: #a31515"&gt;&amp;quot;lb&amp;quot;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ItemsSource=&lt;span style="color: #a31515"&gt;&amp;quot;{Binding Source={x:Static properties:Settings.Default}, Path=Names}&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;That’s all :)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Happy coding !&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Bye.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6971899" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category></item><item><title>[WPF] How to develop and editable Textblock ?</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/03/24/wpf-how-to-develop-and-editable-textblock.aspx</link><pubDate>Tue, 24 Mar 2009 07:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6971887</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>12</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/03/24/wpf-how-to-develop-and-editable-textblock.aspx#comments</comments><description>&lt;P&gt;Here is another request that a friend of mine asked me recently. To achieve this, I’ve just create a custom control that contains a TextBlock and a TextBox (which is hidden) controls. &lt;/P&gt;
&lt;P&gt;When user double clic on the TextBlock, the Textbox appears.&lt;/P&gt;
&lt;P&gt;So here is my proposition: in the file generic.xaml, put this:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 &amp;lt;\cf3 Style\cf0  TargetType=\cf4 "\{x:Type local:EditableTextBlock\}"\cf0 &amp;gt;\par ??        &amp;lt;Setter Property=\cf4 "Template"\cf0 &amp;gt;\par ??            &amp;lt;Setter.Value&amp;gt;\par ??                &amp;lt;\cf3 ControlTemplate\cf0  TargetType=\cf4 "\{x:Type local:EditableTextBlock\}"\cf0 &amp;gt;\par ??                    &amp;lt;Grid x:Name=\cf4 "PART_GridContainer"\cf0  \par ??                          Background=\cf4 "\{TemplateBinding Background\}"\cf0  \par ??                          Width=\cf4 "\{TemplateBinding Width\}"\cf0  \par ??                          Height=\cf4 "\{TemplateBinding Height\}"\cf0 &amp;gt;\par ??                        &amp;lt;\cf3 TextBlock\cf0  x:Name=\cf4 "PART_TbDisplayText"\par ??\cf0                                    \cf3 Visibility\cf0 =\cf4 "Visible"\par ??\cf0                                    Background=\cf4 "\{Binding TextBlockBackgroundColor, RelativeSource=\{RelativeSource AncestorType=\{x:Type local:EditableTextBlock\}\}\}"\par ??\cf0                                    Foreground=\cf4 "\{Binding TextBlockForegroundColor, RelativeSource=\{RelativeSource AncestorType=\{x:Type local:EditableTextBlock\}\}\}"\par ??\cf0                                    Text=\cf4 "\{Binding Text, RelativeSource=\{RelativeSource AncestorType=\{x:Type local:EditableTextBlock\}\}\}"\cf0  /&amp;gt;\par ??                        &amp;lt;\cf3 TextBox\cf0  x:Name=\cf4 "PART_TbEditText"\par ??\cf0                                  \cf3 Visibility\cf0 =\cf4 "Hidden"\par ??\cf0                                  Background=\cf4 "\{Binding TextBoxBackgroundColor, RelativeSource=\{RelativeSource AncestorType=\{x:Type local:EditableTextBlock\}\}\}"\par ??\cf0                                  Foreground=\cf4 "\{Binding TextBoxForegroundColor, RelativeSource=\{RelativeSource AncestorType=\{x:Type local:EditableTextBlock\}\}\}"\par ??\cf0                                  Text=\cf4 "\{Binding Text, RelativeSource=\{RelativeSource AncestorType=\{x:Type local:EditableTextBlock\}\}\}"\cf0  /&amp;gt;\par ??                    &amp;lt;/\cf3 Grid\cf0 &amp;gt;\par ??                &amp;lt;/\cf3 ControlTemplate\cf0 &amp;gt;\par ??            &amp;lt;/\cf3 Setter\cf0 .Value&amp;gt;\par ??        &amp;lt;/\cf3 Setter\cf0 &amp;gt;\par ??    &amp;lt;/\cf3 Style\cf0 &amp;gt;}
--&gt;&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: consolas"&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Style&lt;/SPAN&gt; TargetType=&lt;SPAN style="COLOR: #a31515"&gt;"{x:Type local:EditableTextBlock}"&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setter Property=&lt;SPAN style="COLOR: #a31515"&gt;"Template"&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setter.Value&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;ControlTemplate&lt;/SPAN&gt; TargetType=&lt;SPAN style="COLOR: #a31515"&gt;"{x:Type local:EditableTextBlock}"&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Grid x:Name=&lt;SPAN style="COLOR: #a31515"&gt;"PART_GridContainer"&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Background=&lt;SPAN style="COLOR: #a31515"&gt;"{TemplateBinding Background}"&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Width=&lt;SPAN style="COLOR: #a31515"&gt;"{TemplateBinding Width}"&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Height=&lt;SPAN style="COLOR: #a31515"&gt;"{TemplateBinding Height}"&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;TextBlock&lt;/SPAN&gt; x:Name=&lt;SPAN style="COLOR: #a31515"&gt;"PART_TbDisplayText"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;=&lt;SPAN style="COLOR: #a31515"&gt;"Visible"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Background=&lt;SPAN style="COLOR: #a31515"&gt;"{Binding Mode=TwoWay, Path=TextBlockBackgroundColor, RelativeSource={RelativeSource AncestorType={x:Type local:EditableTextBlock}}}"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Foreground=&lt;SPAN style="COLOR: #a31515"&gt;"{Binding Mode=TwoWay, Path=TextBlockForegroundColor, RelativeSource={RelativeSource AncestorType={x:Type local:EditableTextBlock}}}"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text=&lt;SPAN style="COLOR: #a31515"&gt;"{Binding Mode=TwoWay, Path=Text, RelativeSource={RelativeSource AncestorType={x:Type local:EditableTextBlock}}}"&lt;/SPAN&gt; /&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;TextBox&lt;/SPAN&gt; x:Name=&lt;SPAN style="COLOR: #a31515"&gt;"PART_TbEditText"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;=&lt;SPAN style="COLOR: #a31515"&gt;"Hidden"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Background=&lt;SPAN style="COLOR: #a31515"&gt;"{Binding Mode=TwoWay, Path=TextBoxBackgroundColor, RelativeSource={RelativeSource AncestorType={x:Type local:EditableTextBlock}}}"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Foreground=&lt;SPAN style="COLOR: #a31515"&gt;"{Binding Mode=TwoWay, Path=TextBoxForegroundColor, RelativeSource={RelativeSource AncestorType={x:Type local:EditableTextBlock}}}"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text=&lt;SPAN style="COLOR: #a31515"&gt;"{Binding Mode=TwoWay, Path=Text, RelativeSource={RelativeSource AncestorType={x:Type local:EditableTextBlock}}}"&lt;/SPAN&gt; /&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;SPAN style="COLOR: #2b91af"&gt;Grid&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;SPAN style="COLOR: #2b91af"&gt;ControlTemplate&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;SPAN style="COLOR: #2b91af"&gt;Setter&lt;/SPAN&gt;.Value&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;SPAN style="COLOR: #2b91af"&gt;Setter&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;lt;/&lt;SPAN style="COLOR: #2b91af"&gt;Style&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, here is the content that should go in the behind file:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs20 [\cf3 TemplatePart\cf0 (Type = \cf4 typeof\cf0 (\cf3 Grid\cf0 ), Name = \cf3 EditableTextBlock\cf0 .GRID_NAME)]\par ??    [\cf3 TemplatePart\cf0 (Type = \cf4 typeof\cf0 (\cf3 TextBlock\cf0 ), Name = \cf3 EditableTextBlock\cf0 .TEXTBLOCK_DISPLAYTEXT_NAME)]\par ??    [\cf3 TemplatePart\cf0 (Type = \cf4 typeof\cf0 (\cf3 TextBox\cf0 ), Name = \cf3 EditableTextBlock\cf0 .TEXTBOX_EDITTEXT_NAME)]\par ??    \cf4 public\cf0  \cf4 class\cf0  \cf3 EditableTextBlock\cf0  : \cf3 Control\par ??\cf0     \{\par ??\cf4         #region\cf0  Constants\par ??\par ??        \cf4 private\cf0  \cf4 const\cf0  \cf4 string\cf0  GRID_NAME = \cf5 "PART_GridContainer"\cf0 ;\par ??        \cf4 private\cf0  \cf4 const\cf0  \cf4 string\cf0  TEXTBLOCK_DISPLAYTEXT_NAME = \cf5 "PART_TbDisplayText"\cf0 ;\par ??        \cf4 private\cf0  \cf4 const\cf0  \cf4 string\cf0  TEXTBOX_EDITTEXT_NAME = \cf5 "PART_TbEditText"\cf0 ;\par ??\par ??\cf4         #endregion\par ??\par ??        #region\cf0  Member Fields\par ??\par ??        \cf4 private\cf0  \cf3 Grid\cf0  m_GridContainer;\par ??        \cf4 private\cf0  \cf3 TextBlock\cf0  m_TextBlockDisplayText;\par ??        \cf4 private\cf0  \cf3 TextBox\cf0  m_TextBoxEditText;\par ??\par ??\cf4         #endregion\par ??\par ??        #region\cf0  Dependency Properties\par ??\par ??        \cf4 public\cf0  \cf4 string\cf0  Text\par ??        \{\par ??            \cf4 get\cf0  \{ \cf4 return\cf0  (\cf4 string\cf0 )GetValue(TextProperty); \}\par ??            \cf4 set\cf0  \{ SetValue(TextProperty, \cf4 value\cf0 ); \}\par ??        \}\par ??\par ??        \cf4 public\cf0  \cf4 static\cf0  \cf4 readonly\cf0  \cf3 DependencyProperty\cf0  TextProperty =\par ??            \cf3 DependencyProperty\cf0 .Register(\cf5 "Text"\cf0 , \cf4 typeof\cf0 (\cf4 string\cf0 ), \cf4 typeof\cf0 (\cf3 EditableTextBlock\cf0 ), \cf4 new\cf0  \cf3 UIPropertyMetadata\cf0 (\cf4 string\cf0 .Empty));\par ??\par ??        \cf4 public\cf0  \cf3 Brush\cf0  TextBlockForegroundColor\par ??        \{\par ??            \cf4 get\cf0  \{ \cf4 return\cf0  (\cf3 Brush\cf0 )GetValue(TextBlockForegroundColorProperty); \}\par ??            \cf4 set\cf0  \{ SetValue(TextBlockForegroundColorProperty, \cf4 value\cf0 ); \}\par ??        \}\par ??\par ??        \cf4 public\cf0  \cf4 static\cf0  \cf4 readonly\cf0  \cf3 DependencyProperty\cf0  TextBlockForegroundColorProperty =\par ??            \cf3 DependencyProperty\cf0 .Register(\cf5 "TextBlockForegroundColor"\cf0 , \cf4 typeof\cf0 (\cf3 Brush\cf0 ), \cf4 typeof\cf0 (\cf3 EditableTextBlock\cf0 ), \cf4 new\cf0  \cf3 UIPropertyMetadata\cf0 (\cf4 null\cf0 ));\par ??\par ??        \cf4 public\cf0  \cf3 Brush\cf0  TextBlockBackgroundColor\par ??        \{\par ??            \cf4 get\cf0  \{ \cf4 return\cf0  (\cf3 Brush\cf0 )GetValue(TextBlockBackgroundColorProperty); \}\par ??            \cf4 set\cf0  \{ SetValue(TextBlockBackgroundColorProperty, \cf4 value\cf0 ); \}\par ??        \}\par ??\par ??        \cf4 public\cf0  \cf4 static\cf0  \cf4 readonly\cf0  \cf3 DependencyProperty\cf0  TextBlockBackgroundColorProperty =\par ??            \cf3 DependencyProperty\cf0 .Register(\cf5 "TextBlockBackgroundColor"\cf0 , \cf4 typeof\cf0 (\cf3 Brush\cf0 ), \cf4 typeof\cf0 (\cf3 EditableTextBlock\cf0 ), \cf4 new\cf0  \cf3 UIPropertyMetadata\cf0 (\cf4 null\cf0 ));\par ??\par ??        \cf4 public\cf0  \cf3 Brush\cf0  TextBoxForegroundColor\par ??        \{\par ??            \cf4 get\cf0  \{ \cf4 return\cf0  (\cf3 Brush\cf0 )GetValue(TextBoxForegroundColorProperty); \}\par ??            \cf4 set\cf0  \{ SetValue(TextBoxForegroundColorProperty, \cf4 value\cf0 ); \}\par ??        \}\par ??\par ??        \cf4 public\cf0  \cf4 static\cf0  \cf4 readonly\cf0  \cf3 DependencyProperty\cf0  TextBoxForegroundColorProperty =\par ??            \cf3 DependencyProperty\cf0 .Register(\cf5 "TextBoxForegroundColor"\cf0 , \cf4 typeof\cf0 (\cf3 Brush\cf0 ), \cf4 typeof\cf0 (\cf3 EditableTextBlock\cf0 ), \cf4 new\cf0  \cf3 UIPropertyMetadata\cf0 (\cf4 null\cf0 ));\par ??\par ??        \cf4 public\cf0  \cf3 Brush\cf0  TextBoxBackgroundColor\par ??        \{\par ??            \cf4 get\cf0  \{ \cf4 return\cf0  (\cf3 Brush\cf0 )GetValue(TextBoxBackgroundColorProperty); \}\par ??            \cf4 set\cf0  \{ SetValue(TextBoxBackgroundColorProperty, \cf4 value\cf0 ); \}\par ??        \}\par ??\par ??        \cf4 public\cf0  \cf4 static\cf0  \cf4 readonly\cf0  \cf3 DependencyProperty\cf0  TextBoxBackgroundColorProperty =\par ??            \cf3 DependencyProperty\cf0 .Register(\cf5 "TextBoxBackgroundColor"\cf0 , \cf4 typeof\cf0 (\cf3 Brush\cf0 ), \cf4 typeof\cf0 (\cf3 EditableTextBlock\cf0 ), \cf4 new\cf0  \cf3 UIPropertyMetadata\cf0 (\cf4 null\cf0 ));\par ??\par ??\cf4         #endregion\par ??\par ??        #region\cf0  Constructor\par ??\par ??        \cf4 static\cf0  EditableTextBlock()\par ??        \{\par ??            DefaultStyleKeyProperty.OverrideMetadata(\cf4 typeof\cf0 (\cf3 EditableTextBlock\cf0 ), \cf4 new\cf0  \cf3 FrameworkPropertyMetadata\cf0 (\cf4 typeof\cf0 (\cf3 EditableTextBlock\cf0 )));\par ??        \}\par ??\par ??\cf4         #endregion\par ??\par ??        #region\cf0  Overrides Methods\par ??\par ??        \cf4 public\cf0  \cf4 override\cf0  \cf4 void\cf0  OnApplyTemplate()\par ??        \{\par ??            \cf4 base\cf0 .OnApplyTemplate();\par ??\par ??            \cf4 this\cf0 .m_GridContainer = \cf4 this\cf0 .Template.FindName(GRID_NAME, \cf4 this\cf0 ) \cf4 as\cf0  \cf3 Grid\cf0 ;\par ??\par ??            \cf4 if\cf0 (\cf4 this\cf0 .m_GridContainer != \cf4 null\cf0 )\par ??            \{\par ??                \cf4 this\cf0 .m_TextBlockDisplayText = \cf4 this\cf0 .m_GridContainer.Children[0] \cf4 as\cf0  \cf3 TextBlock\cf0 ;\par ??                \cf4 this\cf0 .m_TextBoxEditText = \cf4 this\cf0 .m_GridContainer.Children[1] \cf4 as\cf0  \cf3 TextBox\cf0 ;\par ??\par ??                \cf4 this\cf0 .m_TextBoxEditText.LostFocus += \cf4 this\cf0 .OnTextBoxLostFocus;\par ??            \}\par ??        \}\par ??\par ??        \cf4 protected\cf0  \cf4 override\cf0  \cf4 void\cf0  OnMouseDoubleClick(\cf3 MouseButtonEventArgs\cf0  e)\par ??        \{\par ??            \cf4 base\cf0 .OnMouseDoubleClick(e);\par ??\par ??            \cf4 this\cf0 .m_TextBlockDisplayText.Visibility = \cf3 Visibility\cf0 .Hidden;\par ??            \cf4 this\cf0 .m_TextBoxEditText.Visibility = \cf3 Visibility\cf0 .Visible;\par ??        \}\par ??\par ??\cf4         #endregion\par ??\par ??        #region\cf0  Event Handlers\par ??\par ??        \cf4 private\cf0  \cf4 void\cf0  OnTextBoxLostFocus(\cf4 object\cf0  sender, \cf3 RoutedEventArgs\cf0  e)\par ??        \{\par ??            \cf4 this\cf0 .m_TextBlockDisplayText.Visibility = \cf3 Visibility\cf0 .Visible;\par ??            \cf4 this\cf0 .m_TextBoxEditText.Visibility = \cf3 Visibility\cf0 .Hidden;\par ??        \}\par ??\par ??\cf4         #endregion\par ??\cf0     \}}
--&gt;&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: consolas"&gt;
&lt;P style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TemplatePart&lt;/SPAN&gt;(Type = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Grid&lt;/SPAN&gt;), Name = &lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;.GRID_NAME)]&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TemplatePart&lt;/SPAN&gt;(Type = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;TextBlock&lt;/SPAN&gt;), Name = &lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;.TEXTBLOCK_DISPLAYTEXT_NAME)]&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TemplatePart&lt;/SPAN&gt;(Type = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;TextBox&lt;/SPAN&gt;), Name = &lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;.TEXTBOX_EDITTEXT_NAME)]&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt; : &lt;SPAN style="COLOR: #2b91af"&gt;Control&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;{&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/SPAN&gt; Constants&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; GRID_NAME = &lt;SPAN style="COLOR: #a31515"&gt;"PART_GridContainer"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; TEXTBLOCK_DISPLAYTEXT_NAME = &lt;SPAN style="COLOR: #a31515"&gt;"PART_TbDisplayText"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; TEXTBOX_EDITTEXT_NAME = &lt;SPAN style="COLOR: #a31515"&gt;"PART_TbEditText"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;#region&lt;/SPAN&gt; Member Fields&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Grid&lt;/SPAN&gt; m_GridContainer;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;TextBlock&lt;/SPAN&gt; m_TextBlockDisplayText;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;TextBox&lt;/SPAN&gt; m_TextBoxEditText;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/SPAN&gt; Dependency Properties&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; Text&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt; { &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;)GetValue(TextProperty); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; { SetValue(TextProperty, &lt;SPAN style="COLOR: blue"&gt;value&lt;/SPAN&gt;); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt; TextProperty = &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: #a31515"&gt;"Text"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;UIPropertyMetadata&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;.Empty));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt; TextBlockForegroundColor&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt; { &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;)GetValue(TextBlockForegroundColorProperty); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; { SetValue(TextBlockForegroundColorProperty, &lt;SPAN style="COLOR: blue"&gt;value&lt;/SPAN&gt;); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt; TextBlockForegroundColorProperty = &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: #a31515"&gt;"TextBlockForegroundColor"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;UIPropertyMetadata&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt; TextBlockBackgroundColor&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt; { &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;)GetValue(TextBlockBackgroundColorProperty); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; { SetValue(TextBlockBackgroundColorProperty, &lt;SPAN style="COLOR: blue"&gt;value&lt;/SPAN&gt;); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt; TextBlockBackgroundColorProperty = &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: #a31515"&gt;"TextBlockBackgroundColor"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;UIPropertyMetadata&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt; TextBoxForegroundColor&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt; { &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;)GetValue(TextBoxForegroundColorProperty); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; { SetValue(TextBoxForegroundColorProperty, &lt;SPAN style="COLOR: blue"&gt;value&lt;/SPAN&gt;); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt; TextBoxForegroundColorProperty = &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: #a31515"&gt;"TextBoxForegroundColor"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;UIPropertyMetadata&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt; TextBoxBackgroundColor&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt; { &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;)GetValue(TextBoxBackgroundColorProperty); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; { SetValue(TextBoxBackgroundColorProperty, &lt;SPAN style="COLOR: blue"&gt;value&lt;/SPAN&gt;); }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt; TextBoxBackgroundColorProperty = &lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: #a31515"&gt;"TextBoxBackgroundColor"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;UIPropertyMetadata&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/SPAN&gt; Constructor&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; EditableTextBlock()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DefaultStyleKeyProperty.OverrideMetadata(&lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;FrameworkPropertyMetadata&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EditableTextBlock&lt;/SPAN&gt;)));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/SPAN&gt; Overrides Methods&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;override&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; OnApplyTemplate()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;base&lt;/SPAN&gt;.OnApplyTemplate();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_GridContainer = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.Template.FindName(GRID_NAME, &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Grid&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_GridContainer != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_TextBlockDisplayText = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_GridContainer.Children[0] &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;TextBlock&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_TextBoxEditText = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_GridContainer.Children[1] &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;TextBox&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_TextBoxEditText.LostFocus += &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.OnTextBoxLostFocus;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;protected&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;override&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; OnMouseDoubleClick(&lt;SPAN style="COLOR: #2b91af"&gt;MouseButtonEventArgs&lt;/SPAN&gt; e)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;base&lt;/SPAN&gt;.OnMouseDoubleClick(e);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_TextBlockDisplayText.Visibility = &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Hidden;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_TextBoxEditText.Visibility = &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Visible;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/SPAN&gt; Event Handlers&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; OnTextBoxLostFocus(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_TextBlockDisplayText.Visibility = &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Visible;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.m_TextBoxEditText.Visibility = &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Hidden;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;}&lt;/P&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, it’s pretty simple but very useful :)&lt;/P&gt;
&lt;P&gt;Happy coding !&lt;/P&gt;
&lt;P&gt;Bye.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6971887" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category></item><item><title>[Blend] XAML &amp; Code Intellisense in Expression Blend 3</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/03/23/blend-xaml-amp-code-intellisense-in-expression-blend-3.aspx</link><pubDate>Mon, 23 Mar 2009 06:29:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6979365</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>1</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/03/23/blend-xaml-amp-code-intellisense-in-expression-blend-3.aspx#comments</comments><description>&lt;P&gt;Version 3 of &lt;STRONG&gt;&lt;A href="http://www.microsoft.com/expression/try-it/blendpreview.aspx" mce_href="http://www.microsoft.com/expression/try-it/blendpreview.aspx"&gt;Expression Blend&lt;/A&gt;&lt;/STRONG&gt;, which is available since last week, comes with a lot of new features. In this features, we can find Intellisense in &lt;STRONG&gt;XAML&lt;/STRONG&gt; files:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_793CC7F9.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_793CC7F9.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=187 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_499EA96D.png" width=510 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_499EA96D.png"&gt;&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;So it’s just a real please for people who, like me, modify the XAML code: no need to open Visual Studio to have Intellisense !&lt;/P&gt;
&lt;P&gt;But, we can also see another interesting point: the code editor (which was present in the very first Beta of Expression Blend and disappear then) now is again available, with Intellisense on C# or VB.NET files:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_074B912A.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_074B912A.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=329 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_2A4BDCCD.png" width=474 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_2A4BDCCD.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_2756781A.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_2756781A.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=254 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_51760035.png" width=479 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_51760035.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;For sure, it’s not a good idea to develop an application using only Expression Blend (don’t fordet that you cannot have breakpoints…) but for doing some tests or prototypes, it’s really nice !&lt;/P&gt;
&lt;P&gt;Happy (Silverlight &amp;amp; WPF) coding ! &lt;/P&gt;
&lt;P&gt;Bye.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6979365" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Expression+Blend/default.aspx">Expression Blend</category></item><item><title>[WPF] Another sample of WPF application using the pattern MVVM</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/03/17/wpf-another-sample-of-wpf-application-using-the-pattern-mvvm.aspx</link><pubDate>Tue, 17 Mar 2009 09:29:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6952705</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>4</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/03/17/wpf-another-sample-of-wpf-application-using-the-pattern-mvvm.aspx#comments</comments><description>&lt;P&gt;To help&amp;nbsp;new developers, here is a sample WPF application (that use the Northwind database) developed by using the pattern &lt;STRONG&gt;MVVM&lt;/STRONG&gt; (&lt;EM&gt;Model View ViewModel&lt;/EM&gt;).&lt;/P&gt;
&lt;P&gt;The goal of this little application is just to give another example that will help to understand this new pattern that is really powerful !&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/thomaslebrun/image_53259820.png" mce_href="http://weblogs.asp.net/blogs/thomaslebrun/image_53259820.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=381 alt=image src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_04645CB4.png" width=508 border=0 mce_src="http://weblogs.asp.net/blogs/thomaslebrun/image_thumb_04645CB4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I will try to make some blog posts about this pattern quickly. In the meantime, just enjoy this :)&lt;/P&gt;
&lt;P&gt;The application can be downloaded here: &lt;A title=http://morpheus.developpez.com/wpf/tools/DemoMVVM.zip href="http://morpheus.developpez.com/wpf/tools/DemoMVVM.zip" mce_href="http://morpheus.developpez.com/wpf/tools/DemoMVVM.zip"&gt;http://morpheus.developpez.com/wpf/tools/DemoMVVM.zip&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Bye.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6952705" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/MVVM/default.aspx">MVVM</category></item><item><title>[WPF] How to assign a dynamic resource from code-behind ?</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/03/11/wpf-how-to-assign-a-dynamic-resource-from-code-behind.aspx</link><pubDate>Wed, 11 Mar 2009 10:46:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6952675</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>0</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/03/11/wpf-how-to-assign-a-dynamic-resource-from-code-behind.aspx#comments</comments><description>&lt;p&gt;When working on WPF projects, it’s mandatory to assign resources to user interface controls. When you work in XAML, it’s pretty simple: you just need to use the &lt;em&gt;MarkupExtension&lt;/em&gt; named &lt;strong&gt;StaticResource&lt;/strong&gt; (or &lt;strong&gt;DynamicResource&lt;/strong&gt; if the resource is going to be modified):&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 &amp;lt;\cf3 Button\cf0  Content=\cf4 "Find Position"\cf0  Click=\cf4 "Button_Click"\cf0  Background=\cf4 "\{DynamicResource brush\}"\cf0  /&amp;gt;}
--&gt;&lt;/p&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: consolas"&gt;   &lt;p style="margin: 0px"&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Button&lt;/span&gt; Content=&lt;span style="color: #a31515"&gt;&amp;quot;Find Position&amp;quot;&lt;/span&gt; Click=&lt;span style="color: #a31515"&gt;&amp;quot;Button_Click&amp;quot;&lt;/span&gt; Background=&lt;span style="color: #a31515"&gt;&amp;quot;{DynamicResource brush}&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;But, how to do the same using code-behind ? The key is to use the method &lt;strong&gt;SetResourceReference&lt;/strong&gt; (&lt;a title="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.setresourcereference.aspx" href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.setresourcereference.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.setresourcereference.aspx&lt;/a&gt;):&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;\red0\green0\blue255;}??\fs20                 &amp;lt;\cf3 Window\cf0 .Resources&amp;gt;\par ??\par ??    &amp;lt;SolidColorBrush x:\cf3 Key\cf0 =\cf4 "brush"\cf0  Color=\cf4 "Red"\cf0  /&amp;gt;\par ??\par ??&amp;lt;/\cf3 Window\cf0 .Resources&amp;gt;\par ??\par ?? \par ??\par ??&amp;lt;Button x:Name=\cf4 "btn"\cf0 Content=\cf4 "Find Position"\cf0  Click=\cf4 "Button_Click"\cf0  /&amp;gt;\par ??\par ??\par ??\par ??\cf5 this\cf0 .btn.SetResourceReference(BackgroundProperty, \cf4 "brush"\cf0 );\par ??}
--&gt;&lt;/p&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: consolas"&gt;   &lt;p style="margin: 0px"&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Window&lt;/span&gt;.Resources&amp;gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;SolidColorBrush x:&lt;span style="color: #2b91af"&gt;Key&lt;/span&gt;=&lt;span style="color: #a31515"&gt;&amp;quot;brush&amp;quot;&lt;/span&gt; Color=&lt;span style="color: #a31515"&gt;&amp;quot;Red&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;lt;/&lt;span style="color: #2b91af"&gt;Window&lt;/span&gt;.Resources&amp;gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;lt;Button x:Name=&lt;span style="color: #a31515"&gt;&amp;quot;btn&amp;quot;&lt;/span&gt;Content=&lt;span style="color: #a31515"&gt;&amp;quot;Find Position&amp;quot;&lt;/span&gt; Click=&lt;span style="color: #a31515"&gt;&amp;quot;Button_Click&amp;quot;&lt;/span&gt; /&amp;gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;.btn.SetResourceReference(BackgroundProperty, &lt;span style="color: #a31515"&gt;&amp;quot;brush&amp;quot;&lt;/span&gt;);&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;As you can see, it’s really simple to use: you define the resource, you define the control and, in code behind, you call the method &lt;em&gt;SetResourceReference&lt;/em&gt; and use the following parameters:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;the DependencyProperty on which the resource will be applied&lt;/li&gt;    &lt;li&gt;the name of the resource&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Happy coding !&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6952675" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category></item><item><title>[WPF] How to gray the icon of a MenuItem ?</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/03/03/wpf-how-to-gray-the-icon-of-a-menuitem.aspx</link><pubDate>Tue, 03 Mar 2009 09:40:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6933907</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>5</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/03/03/wpf-how-to-gray-the-icon-of-a-menuitem.aspx#comments</comments><description>&lt;P&gt;Here is a question that a friend of mine asked me recently. Indeed, as a beginner with WPF, it thought that setting the property IsEnabled = false, on the MenuItem, will disable it. So, the following code:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: consolas"&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;lt;MenuItem Header=&lt;SPAN style="COLOR: #a31515"&gt;"Edit"&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MenuItem x:Name=&lt;SPAN style="COLOR: #a31515"&gt;"miPaste"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Header=&lt;SPAN style="COLOR: #a31515"&gt;"Paste"&lt;/SPAN&gt; IsEnabled=&lt;SPAN style="COLOR: #a31515"&gt;"False"&lt;/SPAN&gt; &amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MenuItem.Icon&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Image Source=&lt;SPAN style="COLOR: #a31515"&gt;"pack://application:,,,/Images/Paste.png"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;/&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MenuItem.Icon&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MenuItem&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;lt;/MenuItem&amp;gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does not deactivate the image, as you can see here:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://morpheus.developpez.com/images/blog/WPFCommentgriserliconedunMenuItemquiestd_7F7F/image_thumb.png" mce_src="http://morpheus.developpez.com/images/blog/WPFCommentgriserliconedunMenuItemquiestd_7F7F/image_thumb.png"&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To correct this, you have 2 choices:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use a second gray image which will be specified as the source for the control if this one is deactivated &lt;/LI&gt;
&lt;LI&gt;Use the class &lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.formatconvertedbitmap.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.formatconvertedbitmap.aspx"&gt;FormatConvertedBitmap&lt;/A&gt;&lt;/STRONG&gt; to create a gray image&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I’ve created a little class, &lt;STRONG&gt;AutoGreyableImage&lt;/STRONG&gt;, which allow you to have an image that will be turn in gray automatically when the control is desactivated.&lt;/P&gt;
&lt;P&gt;Here is how you can use it:&lt;/P&gt;
&lt;P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red163\green21\blue21;}??\fs20 &amp;lt;MenuItem Header=\cf3 "Edit"\cf0 &amp;gt;\par ??                &amp;lt;MenuItem x:Name=\cf3 "miPaste"\par ??\cf0                           Header=\cf3 "Paste"\cf0 &amp;gt;\par ??                    &amp;lt;MenuItem.Icon&amp;gt;\par ??                        &amp;lt;local:AutoGreyableImage Source=\cf3 "pack://application:,,,/Images/Paste.png"\par ??\cf0                                                    /&amp;gt;\par ??                    &amp;lt;/MenuItem.Icon&amp;gt;\par ??                &amp;lt;/MenuItem&amp;gt;\par ??            &amp;lt;/MenuItem&amp;gt;}
--&gt;&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: consolas"&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;lt;MenuItem Header=&lt;SPAN style="COLOR: #a31515"&gt;"Edit"&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MenuItem x:Name=&lt;SPAN style="COLOR: #a31515"&gt;"miPaste"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Header=&lt;SPAN style="COLOR: #a31515"&gt;"Paste"&lt;/SPAN&gt;&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MenuItem.Icon&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;local:AutoGreyableImage Source=&lt;SPAN style="COLOR: #a31515"&gt;"pack://application:,,,/Images/Paste.png"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MenuItem.Icon&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MenuItem&amp;gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;lt;/MenuItem&amp;gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here is the implementation:&lt;/P&gt;
&lt;P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red128\green128\blue128;\red255\green255\blue255;\red0\green128\blue0;\red0\green0\blue0;\red0\green0\blue255;\red43\green145\blue175;}??\fs20 \cf1 ///\cf3  \cf1 &amp;lt;summary&amp;gt;\par ??\cf0     \cf1 ///\cf3  Class used to have an image that is able to be gray when the control is not enabled.\par ??\cf0     \cf1 ///\cf3  Author: Thomas LEBRUN (http://blogs.developpeur.org/tom)\par ??\cf0     \cf1 ///\cf3  \cf1 &amp;lt;/summary&amp;gt;\par ??\cf0     \cf5 public\cf0  \cf5 class\cf0  \cf6 AutoGreyableImage\cf0  : \cf6 Image\par ??\cf0     \{\par ??        \cf1 ///\cf3  \cf1 &amp;lt;summary&amp;gt;\par ??\cf0         \cf1 ///\cf3  Initializes a new instance of the \cf1 &amp;lt;see cref="AutoGreyableImage"/&amp;gt;\cf3  class.\par ??\cf0         \cf1 ///\cf3  \cf1 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf5 public\cf0  AutoGreyableImage()\par ??        \{\par ??            \cf3 // Override the metadata of the IsEnabled property.\par ??\cf0             IsEnabledProperty.OverrideMetadata(\cf5 typeof\cf0 (\cf6 AutoGreyableImage\cf0 ), \cf5 new\cf0  \cf6 FrameworkPropertyMetadata\cf0 (\cf5 true\cf0 , \cf5 new\cf0  \cf6 PropertyChangedCallback\cf0 (OnAutoGreyScaleImageIsEnabledPropertyChanged)));\par ??        \}\par ??\par ??        \cf1 ///\cf3  \cf1 &amp;lt;summary&amp;gt;\par ??\cf0         \cf1 ///\cf3  Called when [auto grey scale image is enabled property changed].\par ??\cf0         \cf1 ///\cf3  \cf1 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf1 ///\cf3  \cf1 &amp;lt;param name="source"&amp;gt;\cf3 The source.\cf1 &amp;lt;/param&amp;gt;\par ??\cf0         \cf1 ///\cf3  \cf1 &amp;lt;param name="args"&amp;gt;\cf3 The \cf1 &amp;lt;see cref="System.Windows.DependencyPropertyChangedEventArgs"/&amp;gt;\cf3  instance containing the event data.\cf1 &amp;lt;/param&amp;gt;\par ??\cf0         \cf5 private\cf0  \cf5 static\cf0  \cf5 void\cf0  OnAutoGreyScaleImageIsEnabledPropertyChanged(\cf6 DependencyObject\cf0  source, \cf6 DependencyPropertyChangedEventArgs\cf0  args)\par ??        \{\par ??            \cf5 var\cf0  autoGreyScaleImg = source \cf5 as\cf0  \cf6 AutoGreyableImage\cf0 ;\par ??            \cf5 var\cf0  isEnable = \cf6 Convert\cf0 .ToBoolean(args.NewValue);\par ??\par ??            \cf5 if\cf0  (autoGreyScaleImg != \cf5 null\cf0 )\par ??            \{\par ??                \cf5 if\cf0  (!isEnable)\par ??                \{\par ??                    \cf3 // Get the source bitmap\par ??\cf0                     \cf5 var\cf0  bitmapImage = \cf5 new\cf0  \cf6 BitmapImage\cf0 (\cf5 new\cf0  \cf6 Uri\cf0 (autoGreyScaleImg.Source.ToString()));\par ??\par ??                    \cf3 // Convert it to Gray\par ??\cf0                     autoGreyScaleImg.Source = \cf5 new\cf0  \cf6 FormatConvertedBitmap\cf0 (bitmapImage, \cf6 PixelFormats\cf0 .Gray32Float, \cf5 null\cf0 , 0);\par ??\par ??                    \cf3 // Create Opacity Mask for greyscale image as FormatConvertedBitmap does not keep transparency info\par ??\cf0                     autoGreyScaleImg.OpacityMask = \cf5 new\cf0  \cf6 ImageBrush\cf0 (bitmapImage);\par ??                \}\par ??                \cf5 else\par ??\cf0                 \{\par ??                    \cf3 // Set the Source property to the original value.\par ??\cf0                     autoGreyScaleImg.Source = ((\cf6 FormatConvertedBitmap\cf0 ) autoGreyScaleImg.Source).Source;\par ??\par ??                    \cf3 // Reset the Opcity Mask\par ??\cf0                     autoGreyScaleImg.OpacityMask = \cf5 null\cf0 ;\par ??                \}\par ??            \}\par ??        \}\par ??    \}}
--&gt;&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: consolas"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; Class used to have an image that is able to be gray when the control is not enabled.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; Author: Thomas LEBRUN (http://blogs.developpeur.org/tom)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;AutoGreyableImage&lt;/SPAN&gt; : &lt;SPAN style="COLOR: #2b91af"&gt;Image&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;{&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; Initializes a new instance of the &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;see cref="AutoGreyableImage"/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; class.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; AutoGreyableImage()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Override the metadata of the IsEnabled property.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsEnabledProperty.OverrideMetadata(&lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;AutoGreyableImage&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;FrameworkPropertyMetadata&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedCallback&lt;/SPAN&gt;(OnAutoGreyScaleImageIsEnabledPropertyChanged)));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; Called when [auto grey scale image is enabled property changed].&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;param name="source"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;The source.&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;param name="args"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;The &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;see cref="System.Windows.DependencyPropertyChangedEventArgs"/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; instance containing the event data.&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; OnAutoGreyScaleImageIsEnabledPropertyChanged(&lt;SPAN style="COLOR: #2b91af"&gt;DependencyObject&lt;/SPAN&gt; source, &lt;SPAN style="COLOR: #2b91af"&gt;DependencyPropertyChangedEventArgs&lt;/SPAN&gt; args)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; autoGreyScaleImg = source &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;AutoGreyableImage&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; isEnable = &lt;SPAN style="COLOR: #2b91af"&gt;Convert&lt;/SPAN&gt;.ToBoolean(args.NewValue);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (autoGreyScaleImg != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (!isEnable)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Get the source bitmap&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; bitmapImage = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;BitmapImage&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;(autoGreyScaleImg.Source.ToString()));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Convert it to Gray&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; autoGreyScaleImg.Source = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;FormatConvertedBitmap&lt;/SPAN&gt;(bitmapImage, &lt;SPAN style="COLOR: #2b91af"&gt;PixelFormats&lt;/SPAN&gt;.Gray32Float, &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;, 0);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Create Opacity Mask for greyscale image as FormatConvertedBitmap does not keep transparency info&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; autoGreyScaleImg.OpacityMask = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;ImageBrush&lt;/SPAN&gt;(bitmapImage);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Set the Source property to the original value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; autoGreyScaleImg.Source = ((&lt;SPAN style="COLOR: #2b91af"&gt;FormatConvertedBitmap&lt;/SPAN&gt;) autoGreyScaleImg.Source).Source;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Reset the Opcity Mask&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; autoGreyScaleImg.OpacityMask = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;}&lt;/P&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the result: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://morpheus.developpez.com/images/blog/WPFCommentgriserliconedunMenuItemquiestd_7F7F/image_thumb_3.png" mce_src="http://morpheus.developpez.com/images/blog/WPFCommentgriserliconedunMenuItemquiestd_7F7F/image_thumb_3.png"&gt; &lt;/P&gt;
&lt;P&gt;You can download the sources (and the demo) here: &lt;A href="http://morpheus.developpez.com/wpf/DisableMenuItemIcon.zip" mce_href="http://morpheus.developpez.com/wpf/DisableMenuItemIcon.zip"&gt;http://morpheus.developpez.com/wpf/DisableMenuItemIcon.zip/wpf/DisableMenuItemIcon.zip&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Happy coding !&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6933907" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category></item><item><title>[WPF] How to be notified when an internal DependencyProperty is modified ?</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/02/27/wpf-how-to-be-notified-when-an-internal-dependencyproperty-is-modified.aspx</link><pubDate>Fri, 27 Feb 2009 10:12:49 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6930411</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>0</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/02/27/wpf-how-to-be-notified-when-an-internal-dependencyproperty-is-modified.aspx#comments</comments><description>&lt;p&gt;When you create your own Dependency Properties, you can define some callbacks that will be called when the value of the property is modified. But, how to do the same with an internal Dependency Property of WPF ?&lt;/p&gt;  &lt;p&gt;Here is a sample:&lt;/p&gt;  &lt;p&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf1 public\cf0  MonControl()\par ??        \{\par ??            \cf4 DependencyPropertyDescriptor\cf0 .FromProperty(WidthProperty, \cf1 typeof\cf0 (MonControl)).AddValueChanged(\cf1 this\cf0 ,\par ??                \cf1 delegate\par ??\cf0                     \{\par ??                        \cf4 MessageBox\cf0 .Show(\cf5 "La valeur a \u233 ?t\u233 ? modifi\u233 ?e !"\cf0 );\par ??                    \});\par ??        \}}
--&gt;&lt;/p&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: consolas"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; MyControl()&lt;/p&gt;    &lt;p style="margin: 0px"&gt;{&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;DependencyPropertyDescriptor&lt;/span&gt;.FromProperty(WidthProperty, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(MyControl)).AddValueChanged(&lt;span style="color: blue"&gt;this&lt;/span&gt;,&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;delegate&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color: #a31515"&gt;&amp;quot;Value has been modified!&amp;quot;&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;/p&gt;    &lt;p style="margin: 0px"&gt;}&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;As you can see, you need to call the &lt;strong&gt;FromProperty&lt;/strong&gt; method of the &lt;strong&gt;DependencyPropertyDescriptor&lt;/strong&gt; class, passing it the Dependency Property that you want to track, the type of your control and then, calling the AddValueChanged method with a delegate to the code that need to be called when the property is modified.&lt;/p&gt;  &lt;p&gt;As you can see, it’s simple but very useful and it appears to be the only way to know when a row is selected on the XCeed datadrig…&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Hope this helps !&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Thanks.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6930411" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Welcome to my English blog !</title><link>http://weblogs.asp.net/thomaslebrun/archive/2009/02/26/welcome-to-my-english-blog.aspx</link><pubDate>Thu, 26 Feb 2009 16:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6929481</guid><dc:creator>Thomas Lebrun</dc:creator><slash:comments>1</slash:comments><comments>http://weblogs.asp.net/thomaslebrun/archive/2009/02/26/welcome-to-my-english-blog.aspx#comments</comments><description>&lt;P&gt;Hello everybody,&lt;/P&gt;
&lt;P&gt;This is my first post on this blog so I’ll try to present myself to let you know who I’m !&lt;/P&gt;
&lt;P&gt;My name is Thomas LEBRUN and I’m currently a consultant and trainer (MCT) at &lt;A href="http://www.winwise.fr/" mce_href="http://www.winwise.fr"&gt;Winwise&lt;/A&gt; in Paris (France). I started to use .NET in 2002, in particular C# language. For my contributions to the french community, Microsoft has honored me with the title of &lt;A href="https://mvp.support.microsoft.com/profile=FF4FF146-E963-4665-9785-B84B6045E86D" mce_href="https://mvp.support.microsoft.com/profile=FF4FF146-E963-4665-9785-B84B6045E86D"&gt;Client Application Development MVP&lt;/A&gt; since 2007. &lt;/P&gt;
&lt;P&gt;My main role is architect on Smart Client technologies: WPF, Silverlight, etc.. I speak at some conferences for Winwise or Microsoft (TechDays), mainly about &lt;STRONG&gt;Windows Presentation Foundation&lt;/STRONG&gt;, &lt;STRONG&gt;Silverlight&lt;/STRONG&gt; and &lt;STRONG&gt;VSTO&lt;/STRONG&gt; (Office Development). &lt;/P&gt;
&lt;P&gt;I’ve a french blog that’s located here: &lt;A href="http://blogs.codes-sources.com/tom" mce_href="http://blogs.codes-sources.com/tom"&gt;http://blogs.codes-sources.com/tom&lt;/A&gt; (fr). This blog mainly devotes itself to Windows Presentation Foundation &amp;amp; Silverlight. Also, I write articles for &lt;A href="http://www.techheadbrothers.com/" mce_href="http://www.techheadbrothers.com/"&gt;http://www.techheadbrothers.com&lt;/A&gt; (fr), &lt;A href="http://ww.developpez.com/" mce_href="http://ww.developpez.com/"&gt;http://ww.developpez.com&lt;/A&gt; (fr) and on a French magazine “Programmez”.&lt;/P&gt;
&lt;P&gt;For my first posts on this blog, I will just translate the posts that are currently on my french blog and I hope they will be useful !&lt;/P&gt;
&lt;P&gt;Thanks !&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: As you will probably doubt, English is not my primary language so, in advance, forgive me for any mistakes I can do [:)]&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6929481" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Personal/default.aspx">Personal</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/MVP/default.aspx">MVP</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/thomaslebrun/archive/tags/.NET/default.aspx">.NET</category></item></channel></rss>
