<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Vincent Sibal's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/vinsibal/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/vinsibal/feed.xml</link>
    <description>WPF Programming Topics</description>
    <lastBuildDate>Sun, 05 Apr 2015 05:35:22 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>New and updated test tools for WPF: TestApi v0.3 and WPF Control Verifier</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/new-and-updated-test-tools-for-wpf-testapi-v0-3-and-wpf-control-verifier</link>
      <pubDate>Tue, 04 Aug 2009 08:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/08/04/new-and-updated-test-tools-for-wpf-testapi-v0-3-and-wpf-control-verifier/</guid>
      <description><![CDATA[TestApi v0.3&nbsp;
The WPF test team has recently released a new version of TestApi!&nbsp; This...]]></description>
      <content:encoded><![CDATA[<P><STRONG>TestApi v0.3&nbsp;</STRONG></P>
<P>The WPF test team has recently released a new version of TestApi!&nbsp; This version includes libraries for fault injection, combinatorial varitation generation, new application control APIs, and updated tests and documentation.&nbsp; I think all the new libraries are really cool, especially the fault injection libraries.&nbsp; Learn more about it <A href="https://testapi.codeplex.com/" mce_href="https://testapi.codeplex.com/">here</A>. </P>
<P><STRONG>WPF Control Verifier&nbsp;v0.1</STRONG></P>
<P>In addition to TestApi, the test team has also developed a tool to verify the behavior of WPF controls.&nbsp; <A href="https://wpf.codeplex.com/Wiki/View.aspx?title=WPF%20Control%20Verifier" mce_href="https://wpf.codeplex.com/Wiki/View.aspx?title=WPF%20Control%20Verifier">WPF Control Verifier</A> is a tool that verifies the correctness of WPF Controls. This tool is geared towards WPF Control developers with the goal of providing a set of verifications that all controls can run and consume. Version 0.1 includes one category for verification – default style verification. These tests verify that your control can be styled such that its dependency properties are inheriting or template binding correctly. Future versions will include additional categories of verification.&nbsp; You can download the tool <A href="https://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30923" mce_href="https://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30923">here</A>.&nbsp; This is our first beta and we will be updating it based on your feedback. We have a planned set of features for future iterations but this will evolve based on your suggestions. Please send your feedback to wpfcvt@microsoft.com.<BR></P>]]></content:encoded>
    </item>
    <item>
      <title>The Control Local Values Bug Solution and new WPF 4.0 related APIs</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/the-control-local-values-bug-solution-and-new-wpf-4-0-related-apis</link>
      <pubDate>Thu, 21 May 2009 10:57:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/05/21/the-control-local-values-bug-solution-and-new-wpf-4-0-related-apis/</guid>
      <description><![CDATA[Intro 
Previously I did a post on the “Control Local Values bug” and how a subtle bug can be...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Intro 
<P mce_keep="true"></FONT></FONT></B><FONT size=3 face=Calibri>Previously I did a post on the </FONT><A href="https://blogs.msdn.com/vinsibal/archive/2009/03/24/the-control-local-values-bug.aspx" mce_href="https://blogs.msdn.com/vinsibal/archive/2009/03/24/the-control-local-values-bug.aspx"><FONT size=3 face=Calibri>“Control Local Values bug”</FONT></A><FONT size=3 face=Calibri> and how a subtle bug can be introduced when setting dependency properties of controls to local values.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In WPF 4.0 (dev10), a mechanism was added to the property engine to solve this problem.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Here are the new APIs in dev10:</FONT></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4f6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">DependencyObject </P></SPAN></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">{&nbsp;</SPAN> 
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"></SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: green; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>// Sets the value of a dependency property without changing its value source.</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> <SPAN style="COLOR: blue">void</SPAN> SetCurrentValue(<SPAN style="COLOR: #2b91af">DependencyProperty</SPAN> dp, <SPAN style="COLOR: blue">object</SPAN> value);<SPAN style="COLOR: blue"> <BR>} </SPAN></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="COLOR: blue">&nbsp;</P></SPAN></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"></P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> <SPAN style="COLOR: blue">struct</SPAN> <SPAN style="COLOR: #2b91af">ValueSource </SPAN></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="COLOR: #2b91af"></SPAN></SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">{&nbsp;</SPAN> 
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"></SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> <SPAN style="COLOR: blue">bool</SPAN> IsCurrent { <SPAN style="COLOR: blue">get</SPAN>; }<SPAN style="COLOR: #2b91af"> </P></SPAN></SPAN>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">}</SPAN><SPAN style="mso-no-proof: yes"> </P></SPAN></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri></FONT></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>Basically, when using DependencyObject.SetCurrentValue instead of DependencyObject.SetValue you set its effective value but its ValueSource remains the same.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is very similar to coercion.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Sample Test App </P></FONT></FONT></B>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>To make it more clear, I wrote a sample test app that shows the BaseValueSource and ValueSource properties when changing a DependencyProperty (DP) via SetCurrentValue. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>I created a custom control with a DP, TitleProperty, where I track its values.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In addition, I setup several scenarios where the TitleProperty is initially set by a particular BaseValueSource.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I’ll go through one scenario here.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>I setup the custom control where the TitleProperty is set from a Style with a binding.<SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN></FONT></FONT>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4f6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Key</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="StyleBindingCustomControlStyle"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> TargetType</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Type</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> local</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">CustomControl</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">}"&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> Property</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="Title"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> RelativeSource</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">={</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">RelativeSource</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> Self</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">},</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Path</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">=WorkingTag,</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>StringFormat</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">='Set</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> via Style w</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">/<SPAN style="COLOR: blue"> Binding: {</SPAN>0<SPAN style="COLOR: blue">}'}" /&gt; </P></SPAN></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> Property</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="Template"&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Setter.Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">ControlTemplate</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> TargetType</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Type</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> local</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">CustomControl</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">}"&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Button</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> Content</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">TemplateBinding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> Title</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">}"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Background</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">TemplateBinding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> Background</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">}" /&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">ControlTemplate</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Setter.Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&gt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&gt; </SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&nbsp;</P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"></P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">GroupBox</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> Header</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="Style Binding"&gt; </P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">local</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">CustomControl</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">Name</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="CustomControl_Style_Binding"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"></P></SPAN>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">StaticResource</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> StyleBindingCustomControlStyle</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">}"/&gt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas"> </P></SPAN>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">GroupBox</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: consolas">&gt; </P></SPAN></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Initially it will look like this:</FONT><SPAN style="mso-no-proof: yes"><SHAPETYPE id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><FONT size=3><FONT face=Calibri> </FONT></FONT></SHAPETYPE></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-no-proof: yes"><SHAPETYPE stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><FONT size=3><FONT face=Calibri><STROKE joinstyle="miter"></STROKE><FORMULAS><F eqn="if lineDrawn pixelLineWidth 0"></F><F eqn="sum @0 1 0"></F><F eqn="sum 0 0 @1"></F><F eqn="prod @2 1 2"></F><F eqn="prod @3 21600 pixelWidth"></F><F eqn="prod @3 21600 pixelHeight"></F><F eqn="sum @0 0 1"></F><F eqn="prod @6 1 2"></F><F eqn="prod @7 21600 pixelWidth"></F><F eqn="sum @8 21600 0"></F><F eqn="prod @7 21600 pixelHeight"></F><F eqn="sum @10 21600 0"></F></FORMULAS><PATH o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></PATH><LOCK aspectratio="t" v:ext="edit"></LOCK></FONT></FONT></SHAPETYPE></SPAN>&nbsp;<A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_1_2.jpg" original-url="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_1_2.jpg" mce_href="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_1_2.jpg"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=CLV_1 border=0 alt=CLV_1 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_1_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_1_thumb.jpg" width=422 height=189 mce_src="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_1_thumb.jpg"></A> </P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Notice the BaseValueSource is ‘Style’, IsExpression is ‘True’, and IsCurrent is ‘False’ as expected.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>After pressing the “Set Current Value” button the values will update accordingly:</FONT><SPAN style="mso-no-proof: yes"></SPAN></P>
<P><FONT size=3 face=Calibri>&nbsp;<A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_2_2.jpg" original-url="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_2_2.jpg" mce_href="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_2_2.jpg"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=CLV_2 border=0 alt=CLV_2 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_2_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_2_thumb.jpg" width=428 height=191 mce_src="https://blogs.msdn.com/blogfiles/vinsibal/WindowsLiveWriter/TheControlLocalValuesBugSol.0relatedAPIs_7368/CLV_2_thumb.jpg"></A> </FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Now the local value has updated to a new string that I set and IsCurrent has updated to ‘True’.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Also notice that BaseValueSource and IsExpression have not changed which is also expected.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you press “Clear Local Value” the values will update back to their initial values.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Now to bring back the original issue with the control local values bug, if you were to set or clear the local value any previous BaseValueSource would be overwritten and any expression lost.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I have created other scenarios in the sample with different BaseValueSource behavior so you can understand how setting the current value behaves in those scenarios.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Please be sure to check it out below.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Usage Recommendation </P></FONT></FONT></B>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>For a control developer, the general recommendation is to always use DependencyObject.SetCurrentValue over DependencyObject.SetValue in Control code.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You’ll notice that our stock controls in the 4.0 framework have all been updated to use this API instead of setting the properties with local values.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri><A href="https://blogs.msdn.com/vinsibal/attachment/9633846.ashx" mce_href="https://blogs.msdn.com/vinsibal/attachment/9633846.ashx">Here</A> is the sample app which works with </FONT><A href="https://www.microsoft.com/downloads/details.aspx?FamilyID=75cbcbcd-b0e8-40ea-adae-85714e8984e3&amp;displaylang=en" mce_href="https://www.microsoft.com/downloads/details.aspx?FamilyID=75cbcbcd-b0e8-40ea-adae-85714e8984e3&amp;displaylang=en"><FONT size=3 face=Calibri>VS 2010 beta 1</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/63/38/46/ControlLocalValuesSample.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-63-38-46/ControlLocalValuesSample.zip">ControlLocalValuesSample.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>VS 2010 and .NET Framework 4.0 Beta1 are out now!</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/vs-2010-and-net-framework-4-0-beta1-are-out-now</link>
      <pubDate>Thu, 21 May 2009 10:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/05/21/vs-2010-and-net-framework-4-0-beta1-are-out-now/</guid>
      <description><![CDATA[As many of you probably already know, dev10 beta1 is available for public download.&nbsp; Some of...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>As many of you probably already know, </FONT><A href="https://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx"><FONT size=3 face=Calibri>dev10 beta1</FONT></A><FONT size=3 face=Calibri> is available for public download.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Some of the additions to Beta1 on the WPF Controls side include:</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>MultiTouch</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>EasingFunctions for animations</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>DataGrid, Calendar, DatePicker, and VisualStateManager in PresentationFramework.dll </FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>New APIs to support the control local values bug</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpLast><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>And tons of bug fixes on the new controls as well as existing control and element services areas</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>I’ll be going over some of these new features in more depth so stay tuned!</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>WPF Model-View-ViewModel (MVVM) Toolkit 0.1</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/wpf-model-view-viewmodel-mvvm-toolkit-0-1</link>
      <pubDate>Sat, 02 May 2009 10:59:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/05/02/wpf-model-view-viewmodel-mvvm-toolkit-0-1/</guid>
      <description><![CDATA[The WPF team has just released an MVVM Toolkit which contains an overview and walkthrough of the...]]></description>
      <content:encoded><![CDATA[The WPF team has just released an MVVM Toolkit which contains an overview and walkthrough of the MVVM pattern, a full Messenger sample app using MVVM, as well as a Visual Studio template for MVVM.&nbsp; The template creates a WPF application with folders for Views, ViewModels, Models, and Commands.&nbsp; What I really like about it is the DelegateCommand class which is similar to <A href="https://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090030" mce_href="https://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090030">RelayCommand</A>.&nbsp; One addition to this version of the Command implementation is the ability to manually control&nbsp;when OnCanExecuteChanged is called or let the CommandManager control it.&nbsp; The common scenario will be the latter, but&nbsp;allowing the option for the former will allow greater control over application performance due to the many calls to OnCanExecuteChanged.&nbsp; In the future, the plan is to get this as well as other MVVM concepts into the WPF framework.&nbsp; You can learn more about it <A href="https://wpf.codeplex.com/Wiki/View.aspx?title=WPF%20Model-View-ViewModel%20Toolkit" mce_href="https://wpf.codeplex.com/Wiki/View.aspx?title=WPF%20Model-View-ViewModel%20Toolkit">here</A>&nbsp;and download it <A href="https://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=14962" mce_href="https://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=14962">here</A>.&nbsp; Check it out and we would love to hear your feedback.&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>WPF TestApi v0.2 has released!</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/wpf-testapi-v0-2-has-released</link>
      <pubDate>Fri, 24 Apr 2009 13:39:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/04/24/wpf-testapi-v0-2-has-released/</guid>
      <description><![CDATA[The WPF test team is hard at work to provide value through a simple and componetized library...]]></description>
      <content:encoded><![CDATA[<P>The WPF test team is hard at work to provide value through a simple and componetized library of&nbsp;public test APIs.&nbsp; The <A class="" href="https://www.codeplex.com/TestApi" mce_href="https://www.codeplex.com/TestApi">WPF TestAp</A>i library has just released a <A class="" href="https://testapi.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=26566" mce_href="https://testapi.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=26566">v0.2</A> which includes new visual verification features, command line parsing features, an auomated application controller, and new unit test samples.&nbsp; </P>
<P>Ivo has a great post about the visual verification APIs and usage&nbsp;that you can view <A class="" href="https://blogs.msdn.com/ivo_manolov/archive/2009/04/20/9557563.aspx" mce_href="https://blogs.msdn.com/ivo_manolov/archive/2009/04/20/9557563.aspx">here</A>.&nbsp; Please try it out and let us know your feedback!</P>]]></content:encoded>
    </item>
    <item>
      <title>5 More Random Gotchas with the WPF DataGrid</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/5-more-random-gotchas-with-the-wpf-datagrid</link>
      <pubDate>Tue, 14 Apr 2009 09:21:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/04/14/5-more-random-gotchas-with-the-wpf-datagrid/</guid>
      <description><![CDATA[1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataGridColumn.SortDirection does not actually sort the...]]></description>
      <content:encoded><![CDATA[<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>1.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>DataGridColumn.SortDirection does not actually sort the column.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>DataGridColumn.SortDirection is used to queue the visual arrow in the DataGridColumnHeader to point up, down, or to not show.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To actually sort the columns other than clicking on the DataGridColumnHeader, you can set the DataGrid.Items.SortDescriptions programmatically.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>Here is an example of an ICommand used to trigger grouping of a particular column in the DataGrid.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In addition to grouping it, I also sort it on the same column name that I grouped it with.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Note that this code will programmatically sort the column but will not update the sorting arrow since I did not update SortDirection. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></FONT></FONT></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: #2b91af">ICommand</SPAN> GroupColumn<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>get<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{<SPAN style="mso-tab-count: 1"> </SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (_groupColumn == <SPAN style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>_groupColumn = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">RelayCommand</SPAN>&lt;<SPAN style="COLOR: blue">object</SPAN>&gt;(<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>(param) =&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// the delegate is passed in the column header<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// name which matches the Binding on the column</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>string</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> header = param <SPAN style="COLOR: blue">as</SPAN> <SPAN style="COLOR: blue">string</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// <o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// SearchResults is the ItemsSource that DataGrid<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// is bound to. Below I programmatically group and<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>// sort the collection based on the header name<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>//<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>SearchResults.GroupDescriptions.Add(<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">PropertyGroupDescription</SPAN>(header));<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>SearchResults.SortDescriptions.Add(<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">SortDescription</SPAN>(header, <SPAN style="COLOR: #2b91af">ListSortDirection</SPAN>.Ascending));<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>});<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> _groupColumn;<SPAN style="COLOR: blue"><BR><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>}</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><SPAN style="mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal><o:p><FONT size=3 face=Calibri></FONT></o:p>&nbsp;</P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>2.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>DataGridColumns cannot be styled as they are not FrameworkElements.<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>DataGridColumn derives from DependencyObject, not FrameworkElement, and therefore cannot be styled like many of the other elements on DataGrid.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You can think of a DataGridColumn as data storage for what each cell’s content will be template with and a couple other properties like the width of each cell and how it is sorted.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>They are not meant to be visual elements like DataGridCell or DataGridRow.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>3.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>While editing a row, the row is committed by pressing Enter, pressing tab on the last cell of the row, losing focus, clicking the column header to sort the column, programmatically calling DataGrid.CommitEdit, updating DataGrid.CurrentCell to a cell outside the current row, or updating DataGrid.CurrentItem.<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>The actions described above are the default actions to commit a row.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>One action that deserves a little more clarification is the commit on losing focus. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Each DataGridCell listens for changes to its IsKeyboardFocusWithin property and when it changes it updates the CurrentCell accordingly (which causes the row to commit).</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>4.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Disable commit behavior through the DataGrid.RowEditEnding event<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>In the previous gotcha I explain all the ways that a row can be committed.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you want to customize that behavior, the best way to do it is through DataGrid.RowEditEnding.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This event is fired at the start of any and all row commits and you have the ability to cancel the commit behavior in this event through DataGridRowEditEndingEventArgs.Cancel.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>See more about editing behavior </FONT><A href="https://blogs.msdn.com/vinsibal/archive/2008/10/01/overview-of-the-editing-features-in-the-wpf-datagrid.aspx" mce_href="https://blogs.msdn.com/vinsibal/archive/2008/10/01/overview-of-the-editing-features-in-the-wpf-datagrid.aspx"><FONT size=3 face=Calibri>here</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>5.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Customize focus behavior after a row commit through the DataGrid.RowEditEnding event <o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>While there isn’t a DataGrid.RowEditEnded at this time (March 2009 Release), you can use the Dispatcher trick to get custom behavior after a row commit has occurred.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In DataGrid.RowEditEnding, you can specify a Dispatcher.BeginInvoke so that the code in the delegate is executed after the row commit has completed.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Here is some example code which sets focus to the second cell of the next row and puts it in edit mode but only when I press tab on the last cell of the row before the NewItemPlaceholder.</FONT><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">private</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">void</SPAN> OnRowEditEnding(<SPAN style="COLOR: blue">object</SPAN> sender, <SPAN style="COLOR: #2b91af">DataGridRowEditEndingEventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (e.EditAction == <SPAN style="COLOR: #2b91af">DataGridEditAction</SPAN>.Commit)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>//<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>// custom commit action:<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>// tab specific behavior for editing workflow.<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>// moves to the next row and opens the second cell for edit<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>// if the next row is the NewItemPlaceholder<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>//<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (_isTabPressed &amp;&amp; <o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>e.Row.Item == dataGrid.Items[dataGrid.Items.Count - 2])<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// set the new cell to be the last row and the second column<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>int</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> colIndex = 1;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> rowToSelect = dataGrid.Items[dataGrid.Items.Count - 1];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> colToSelect = dataGrid.Columns[colIndex];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>int</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> rowIndex = dataGrid.Items.IndexOf(rowToSelect);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// select the new cell<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>dataGrid.SelectedCells.Clear();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>dataGrid.SelectedCells.Add(<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN><SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">DataGridCellInfo</SPAN>(rowToSelect, colToSelect));<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>this</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">.Dispatcher.BeginInvoke(<SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">DispatcherOperationCallback</SPAN>((param) =&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// get the new cell, set focus, then open for edit<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> cell = <SPAN style="COLOR: #2b91af">Helper</SPAN>.GetCell(dataGrid, rowIndex, colIndex);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>cell.Focus();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>dataGrid.BeginEdit();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}), <SPAN style="COLOR: #2b91af">DispatcherPriority</SPAN>.Background, <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: blue">object</SPAN>[] { <SPAN style="COLOR: blue">null</SPAN> });<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><SPAN style="mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>See more </FONT><A href="https://blogs.msdn.com/vinsibal/archive/2009/04/07/5-random-gotchas-with-the-wpf-datagrid.aspx" mce_href="https://blogs.msdn.com/vinsibal/archive/2009/04/07/5-random-gotchas-with-the-wpf-datagrid.aspx"><FONT size=3 face=Calibri>WPF DataGrid gotchas</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>]]></content:encoded>
    </item>
    <item>
      <title>Launching a custom Dialog to edit items in a DataGrid (with MVVM)</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/launching-a-custom-dialog-to-edit-items-in-a-datagrid-with-mvvm</link>
      <pubDate>Fri, 10 Apr 2009 09:53:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/04/10/launching-a-custom-dialog-to-edit-items-in-a-datagrid-with-mvvm/</guid>
      <description><![CDATA[Launching a custom dialog for editing on the DataGrid is another somewhat common request that I see...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Launching a custom dialog for editing on the DataGrid is another somewhat common request that I see from the </FONT><A href="https://wpf.codeplex.com/Thread/List.aspx" mce_href="https://wpf.codeplex.com/Thread/List.aspx"><FONT size=3 face=Calibri>discussion list</FONT></A><FONT size=3 face=Calibri>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I thought I would provide a sample but at the same time implement it with the MVVM pattern.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The requirement that I will use on the sample is that the editing mechanism can only come from the editing dialog that I provide.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>I decided that the way to launch the custom dialog will be through double-clicking on the row.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To get that behavior, I will use the </FONT><A href="https://blogs.msdn.com/johngossman/archive/2008/05/07/the-attached-behavior-pattern.aspx" mce_href="https://blogs.msdn.com/johngossman/archive/2008/05/07/the-attached-behavior-pattern.aspx"><FONT size=3 face=Calibri>attached behavior pattern</FONT></A><FONT size=3 face=Calibri> on DataGridRow.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The behavior is defined like so:</FONT></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-element: para-border-div; mso-border-themecolor: accent3; mso-border-themeshade: 128">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">DataGridRowBehavior</SPAN><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: #2b91af">DependencyProperty</SPAN> OnDoubleClickProperty = <SPAN style="COLOR: #2b91af">DependencyProperty</SPAN>.RegisterAttached(<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>"OnDoubleClick"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">,<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>typeof</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">(<SPAN style="COLOR: #2b91af">ICommand</SPAN>),<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>typeof</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">(<SPAN style="COLOR: #2b91af">DataGridRowBehavior</SPAN>),<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>new</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: #2b91af">UIPropertyMetadata</SPAN>(<SPAN style="COLOR: #2b91af">DataGridRowBehavior</SPAN>.OnDoubleClick));<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">void</SPAN> SetOnDoubleClick(<SPAN style="COLOR: #2b91af">DependencyObject</SPAN> target, <SPAN style="COLOR: #2b91af">ICommand</SPAN> value)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>target.SetValue(<SPAN style="COLOR: #2b91af">DataGridRowBehavior</SPAN>.OnDoubleClickProperty, value);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>private</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">void</SPAN> OnDoubleClick(<SPAN style="COLOR: #2b91af">DependencyObject</SPAN> target, <SPAN style="COLOR: #2b91af">DependencyPropertyChangedEventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> element = target <SPAN style="COLOR: blue">as</SPAN> <SPAN style="COLOR: #2b91af">DataGridRow</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> ((e.NewValue != <SPAN style="COLOR: blue">null</SPAN>) &amp;&amp; (e.OldValue == <SPAN style="COLOR: blue">null</SPAN>))<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>element.PreviewMouseDoubleClick += OnPreviewMouseDoubleClick;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>else</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">if</SPAN> ((e.NewValue == <SPAN style="COLOR: blue">null</SPAN>) &amp;&amp; (e.OldValue != <SPAN style="COLOR: blue">null</SPAN>))<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>element.PreviewMouseDoubleClick -= OnPreviewMouseDoubleClick;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>private</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">void</SPAN> OnPreviewMouseDoubleClick(<SPAN style="COLOR: blue">object</SPAN> sender, <SPAN style="COLOR: #2b91af">MouseButtonEventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>UIElement</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> element = (<SPAN style="COLOR: #2b91af">UIElement</SPAN>)sender;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ICommand</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> command = (<SPAN style="COLOR: #2b91af">ICommand</SPAN>)element.GetValue(<SPAN style="COLOR: #2b91af">DataGridRowBehavior</SPAN>.OnDoubleClickProperty);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>command.Execute(e);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><SPAN style="mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>The behavior is then used on the DataGridRow like this:</FONT><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-element: para-border-div; mso-border-themecolor: accent3; mso-border-themeshade: 128">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> TargetType</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Type</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> toolkit</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">DataGridRow</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}"&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Property</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="local:DataGridRowBehavior.OnDoubleClick"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> <o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> ShowEditItemDialogCommand</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}" /&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;</SPAN><SPAN style="mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>What’s happening is the OnDoubleClick attached property listens for a property change on itself.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I define an ICommand, ShowEditItemDialogCommand, on OnDoubleClick which then hooks up the actual event handler, PreviewMouseDoubleClick, on the target element.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In that event handler, OnPreviewMouseDoubleClick, I retrieve the value of OnDoubleClick which is my ICommand and execute it. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>So now we have the behavior to launch a dialog through a double-click action.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The next thing is to define the ICommand ShowEditItemDialogCommand.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>I have defined a DataGridRow ViewModel which hosts the actual item data as well as any properties that will drive the view (the DataGridRow).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It also will host any commands on a DataGridRow which for our purposes will be the ShowEditItemDialogCommand.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>My commands are also implemented using the RelayCommand mechanism that is discussed on this </FONT><A href="https://msdn.microsoft.com/en-us/magazine/dd419663.aspx" mce_href="https://msdn.microsoft.com/en-us/magazine/dd419663.aspx"><FONT size=3 face=Calibri>MSDN article</FONT></A><FONT size=3 face=Calibri>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>So here is the basic implementation:</FONT><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-element: para-border-div; mso-border-themecolor: accent3; mso-border-themeshade: 128">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">ItemViewModel</SPAN> : <SPAN style="COLOR: #2b91af">ViewModelBase<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>private</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: #2b91af">ICommand</SPAN> _editItemCommand;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>public</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: #2b91af">ICommand</SPAN> ShowEditItemDialogCommand<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>get<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1"></SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (_editItemCommand == <SPAN style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1"></SPAN><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>_editItemCommand = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">RelayCommand</SPAN>(<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp; </SPAN>() =&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// pass the item to the dialog</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> dlg = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">EditItemDialog</SPAN>(Item);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (dlg.ShowDialog() == <SPAN style="COLOR: blue">true</SPAN>)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>// retrieve the updated item from the dialog</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>Item = dlg.Result.Item;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>});<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>return</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> _editItemCommand;<SPAN style="COLOR: blue"><BR><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1"> </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>}</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><SPAN style="mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>So when DataGridRowBehavior.OnPreviewMouseDoubleClick executes the command, my ShowEditItemDialogCommand will initiate the launch of the new dialog.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The dialog that is being launched is basically a new Window which is considered a View.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>From a MVVM purist perspective this does not belong in a ViewModel.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To handle this you can use the </FONT><A href="https://en.wikipedia.org/wiki/Mediator_pattern" mce_href="https://en.wikipedia.org/wiki/Mediator_pattern"><FONT size=3 face=Calibri>mediator</FONT></A><FONT size=3 face=Calibri> design pattern to host the communication between the ViewModel and the View.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>There are a couple ways to implement this pattern which include implementing it as an observer pattern or using a specialized communication mechanism through interfaces and references. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>I’ve chosen the latter and in the sample code you can see I’ve named it EditDialogDirector to be clear on&nbsp;its behavior.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I won’t show all the details here.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Now, I said earlier that I set a requirement that editing can only come from the dialog that I provide.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>While there are a lot of ways to customize the editing behavior, I decided to keep it really simple and set DataGrid.IsReadOnly to true.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It does mean that I will lose the default editing capabilities that DataGrid provides, but I won’t have to keep state on DataGrid begin and commit edits.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>There are some other details that I’m leaving out but the full sample code below will give you a good idea of how everything is pieced together.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Also, there is a lot of great reference material and samples on MVVM to further enhance your knowledge on the subject.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><A href="https://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx" mce_href="https://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx"><FONT size=3 face=Calibri>https://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx</FONT></A></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><A href="https://karlshifflett.wordpress.com/mvvm/" mce_href="https://karlshifflett.wordpress.com/mvvm/"><FONT size=3 face=Calibri>https://karlshifflett.wordpress.com/mvvm/</FONT></A></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><A href="https://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx" mce_href="https://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx"><FONT size=3 face=Calibri>https://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx</FONT></A></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Download the full sample <A href="https://blogs.msdn.com/vinsibal/attachment/9543268.ashx" mce_href="https://blogs.msdn.com/vinsibal/attachment/9543268.ashx">here</A>.</FONT><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/54/32/68/DataGridMVVMEditingSample.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-54-32-68/DataGridMVVMEditingSample.zip">DataGridMVVMEditingSample.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>5 Random Gotchas with the WPF DataGrid</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/5-random-gotchas-with-the-wpf-datagrid</link>
      <pubDate>Tue, 07 Apr 2009 09:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/04/07/5-random-gotchas-with-the-wpf-datagrid/</guid>
      <description><![CDATA[Since the release of the WPF DataGrid there have been several&nbsp;common patterns of...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Since the release of the WPF DataGrid there have been several&nbsp;common patterns of questions&nbsp;that developers were asking on the&nbsp;<A href="https://wpf.codeplex.com/Thread/List.aspx" mce_href="https://wpf.codeplex.com/Thread/List.aspx">discussion list</A>.&nbsp; I thought that I would capture some of that here so it would be easy to find.&nbsp; I'll also try to keep it as short as possible and refer to other links for more information.&nbsp; These gotchas are in no particular order.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>1.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>DataGridColumns are not part of the visual tree.&nbsp; <o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Since a DataGridColumn has a Binding DP it is easy to think that bindings to other DataGridColumn DPs will work just the same but they don't.&nbsp; Below is an example showing a DataGridCheckBoxColumn setting the Binding DP and CanUserSort through data binding.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>While Binding will bind correctly, CanUserSort will not.</FONT><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: red"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><o:p></o:p></SPAN></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">dg</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">DataGridCheckBoxColumn</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Header</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="Selection"<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> IsSelected</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: red">CanUserSort</SPAN><SPAN style="COLOR: blue">="{</SPAN><SPAN style="COLOR: #a31515">Binding</SPAN><SPAN style="COLOR: red"> CanSort</SPAN><SPAN style="COLOR: blue">}"/&gt;</SPAN><SPAN style="COLOR: #a31515"><o:p></o:p></SPAN></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Note that the reason Binding does work is because the internal code dynamically sets the binding of DataGridColumn.Binding to the DataGridCell.Content.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It does not do so for the other DataGridColumn DPs.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Workaround =&gt; Check out </FONT><A href="https://blogs.msdn.com/jaimer/archive/2008/11/22/forwarding-the-datagrid-s-datacontext-to-its-columns.aspx"><FONT size=3 face=Calibri>Jaime’s post</FONT></A><FONT size=3 face=Calibri> on how to get the DataGridColumns to use the same DataContext as the DataGrid. </FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>2.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>DataGridColumn.Binding will automatically&nbsp;coerce the binding to BindingMode.TwoWay and UpdateSourceTrigger.Explicit<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>No matter how you declare the binding for DataGridColumn.Binding, internally it will coerce the BindingMode to TwoWay and UpdateSourceTrigger to Explicit (even if you set them explicitly yourself).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is because the DataGrid manages the binding operations itself for editing functionality.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Now, you might run into an issue when you have a read-only property with a TwoWay binding mode.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you set DataGridColumn.IsReadOnly to true, then the BindingMode will not be coerced to TwoWay.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>3.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>You manage the bindings when using a DataGridTemplateColumn.<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>The DataGrid internal code does not coerce the bindings set on DataGridTemplateColumn because DataGridTemplateColumn doesn’t even have a Binding DP.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Since you are setting the bindings up yourself, you have to tell it when to commit.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>One common way to do this is to setup a OneWay binding on the UIElement in the CellTemplate and a TwoWay binding on the CellEditingTemplate.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>See this previous </FONT><A href="https://blogs.msdn.com/vinsibal/archive/2008/08/19/wpf-datagrid-stock-and-template-columns.aspx"><FONT size=3 face=Calibri>post</FONT></A><FONT size=3 face=Calibri> for example code (under “Template Columns”).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The example code uses an UpdateSourceTrigger of PropertyChanged.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If that does not suite your needs for committing the data, you can mimic what the DataGrid internal code does and update the source yourself.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Set the UpdateSourceTrigger to Explicit and listen to the DataGrid.CellEditEnding event.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You can then update the source explicitly in that event.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>4.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Use DataGridColumn.ElementStyle and DataGridColumn.EditingElementStyle to set properties on a cell’s Content.<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Each stock DataGridColumn type produces a specific type of Control as the content for each DataGridCell in the column.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>See this previous </FONT><A href="https://blogs.msdn.com/vinsibal/archive/2008/08/19/wpf-datagrid-stock-and-template-columns.aspx"><FONT size=3 face=Calibri>post</FONT></A><FONT size=3 face=Calibri> for more info on that.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It seems that the first instinct to set properties on the cell’s content is to set them through the DataGridCell Style when they should instead be set on DataGridColumn.ElementStyle and/or DataGridColumn.EditingElementStyle.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>ElementStyle is the Style applied to the non-editing element.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>EditingElementStyle is for the editing element.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>In a previous gotcha, I mention that DataGridColumns are not part of the visual tree.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>With that said, you can still create bindings that map to the same DataContext as DataGridColumn.Binding on DPs from a Style set on DataGridColumn.ElementStyle and DataGridColumn.EditingElementStyle.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>That is because these styles are applied dynamically to the cell’s content which has the correct DataContext. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Below I am setting a DataGridTextBoxColumn’s ElementStyle.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Notice that I have a binding setup on Background with a “MyBrush” property path.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I am assuming that property is coming from the DataContext of the DataGridCell (which is the same DataContext of the DataGridRow).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: red"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: red"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: red"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><SPAN style="COLOR: blue"><o:p></o:p></SPAN></SPAN></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">dg</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">DataGridTextColumn</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Header</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="First Name"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"> <o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Path</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">=FirstName}"&gt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">dg</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">DataGridTextColumn.ElementStyle</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> TargetType</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Type</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> TextBlock</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}"&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Property</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="ToolTip"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">StaticResource</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> TextToolTip</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}" /&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Property</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="Background"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> MyBrush</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}" /&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Property</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="TextWrapping"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="Wrap" /&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">dg</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">DataGridTextColumn.ElementStyle</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">dg</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">DataGridTextColumn</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;</SPAN><SPAN style="mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph><B style="mso-bidi-font-weight: normal"><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>5.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN></B><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Data source items should implement IEditableObject to get transactional editing functionality.<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>If you are not familiar with IEditableObject, see this MSDN </FONT><A href="https://msdn.microsoft.com/en-us/library/system.componentmodel.ieditableobject.aspx"><FONT size=3 face=Calibri>article</FONT></A><FONT size=3 face=Calibri> which has a good explanation and code sample.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The DataGrid has baked in functionality for transactional editing via the IEditableObject interface.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>When you begin editing a cell, the DataGrid gets into cell editing mode as well as row editing mode.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>What this means is that you can cancel/commit cells as well as cancel/commit rows.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, I edit cell 0 and press tab to the next cell.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Cell 0 is committed when pressing tab.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I start typing in cell 1 and realize I want to cancel the operation.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I press ‘Esc’ which reverts cell 1.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I now realize I want to cancel the whole operation so I press ‘Esc’ again and now cell 0 is reverted back to its original value.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>See more <A href="https://blogs.msdn.com/vinsibal/archive/2009/04/14/5-more-random-gotchas-with-the-wpf-datagrid.aspx" mce_href="https://blogs.msdn.com/vinsibal/archive/2009/04/14/5-more-random-gotchas-with-the-wpf-datagrid.aspx">WPF DataGrid&nbsp;gotchas</A>.</FONT></o:p></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>]]></content:encoded>
    </item>
    <item>
      <title>The Control Local Values Bug!</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/the-control-local-values-bug</link>
      <pubDate>Tue, 24 Mar 2009 16:06:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/03/24/the-control-local-values-bug/</guid>
      <description><![CDATA[Intro
WPF dependency properties are properties that are registered through the WPF property...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT face=Calibri><FONT size=3>Intro<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><A href="https://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx" mce_href="https://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx"><FONT size=3 face=Calibri>WPF dependency properties</FONT></A><FONT size=3 face=Calibri> are properties that are registered through the WPF property system.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>By registering with the property system, the property will be provided a set of services such as data binding, styling, change notifications, animation, expressions, invalidation, and coercion.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>What I will be discussing here is dynamic value resolution and the issue of setting local values in controls.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT face=Calibri><FONT size=3>Background<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>A dependency property’s value is dependent on multiple providers where there is a level of precedence for each provider.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The </FONT><A href="https://msdn.microsoft.com/en-us/library/system.windows.basevaluesource.aspx" mce_href="https://msdn.microsoft.com/en-us/library/system.windows.basevaluesource.aspx"><FONT size=3 face=Calibri>BaseValueSource</FONT></A><FONT size=3 face=Calibri> enum captures these providers (with the first being the lowest precedence and last being the highest)</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Unknown</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Default</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Inherited</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>ThemeStyle</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>ThemeStyleTrigger</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Style</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>TemplateTrigger</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>StyleTrigger</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>ImplicitStyleReference</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>ParentTemplate</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>PatentTemplateTrigger</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpLast><SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"><SPAN style="mso-list: Ignore"><FONT size=3>·</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Local</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>In addition to these base value sources, the dependency property can also come from an expression, animation, or coercion (which the internal WPF code represents them as ModifiedValues).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Note that ModifiedValues are mutually exclusive from BaseValueSource.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example you can have a value that is set locally and coerced at the same time. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>So how does this relate to the control local values bug?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>As a control author, dependency properties are the general mechanism to communicate the state and behavior of the control.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>They will be used in data binding scenarios, visual representation, interaction, etc.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This means that you will possibly and most likely be setting values on your dependency properties internally as state changes about your control.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>So as you are setting new values to a dependency property that you own, you may not realize that you are introducing a very subtle bug relating to dynamic value resolution precedence.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I’ll use an example to clarify. </FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>The DatePicker control from WPFToolkit has a DP called IsDropDownOpen.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It is used by the DatePicker control to update when the calendar popup opens and closes.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It listens for a change event and sets the Popup.IsOpen accordingly.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">private</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">void</SPAN> OnIsDropDownOpenChanged(<SPAN style="COLOR: #2b91af">DependencyObject</SPAN> d, <SPAN style="COLOR: #2b91af">DependencyPropertyChangedEventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>DatePicker</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> dp = d <SPAN style="COLOR: blue">as</SPAN> <SPAN style="COLOR: #2b91af">DatePicker</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>Debug</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">.Assert(dp != <SPAN style="COLOR: blue">null</SPAN>);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>bool</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> newValue = (<SPAN style="COLOR: blue">bool</SPAN>)e.NewValue;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (dp._popUp != <SPAN style="COLOR: blue">null</SPAN> &amp;&amp; dp._popUp.IsOpen != newValue)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>dp._popUp.IsOpen = newValue;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><SPAN style="mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri></FONT></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>The Popup also listens for when it opens and closes and makes sure IsDropDownOpen is toggled to the correct state.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">private</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">void</SPAN> PopUp_Opened(<SPAN style="COLOR: blue">object</SPAN> sender, <SPAN style="COLOR: #2b91af">EventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>if</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (!<SPAN style="COLOR: blue">this</SPAN>.IsDropDownOpen)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>this</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">.IsDropDownOpen = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>…<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Notice the bug?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The bug lies in PopUp_Opened when setting IsDropDownOpen to a local value.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This really appears harmless and you probably won’t actually see the bug in action until you hand it over to the app developer who will actually set different value providers on your control DPs.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The problem is that setting a DP locally as an internal operation in your control will trump any and all value providers set on that DP (as local is the highest precedence).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>That means that the app developer who uses your control and decides to put some fancy styles, binding, triggers, and all that goodness will find that it will stop working for some reason and not immediately know what caused it. </FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>To further describe how this can occur, here is an example using that same DatePicker (note that this has already been fixed in later version of the toolkit).</FONT><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<DIV style="BORDER-BOTTOM: #4f6228 1pt dashed; BORDER-LEFT: #4f6228 1pt dashed; PADDING-BOTTOM: 5pt; PADDING-LEFT: 5pt; PADDING-RIGHT: 5pt; BACKGROUND: #f6f5f0; MARGIN-LEFT: 0.1in; BORDER-TOP: #4f6228 1pt dashed; MARGIN-RIGHT: 0in; BORDER-RIGHT: #4f6228 1pt dashed; PADDING-TOP: 5pt; mso-border-alt: dash-small-gap #4F6228 .5pt; mso-border-themecolor: accent3; mso-border-themeshade: 128; mso-element: para-border-div">
<P style="MARGIN: 12pt 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpFirst><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Window.Resources</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">Key</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="DatePickerStyle"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> TargetType</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">x</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Type</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> toolkit</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">DatePicker</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}"&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Setter</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Property</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="IsDropDownOpen"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Value</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Binding</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> ElementName</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">=cb_IsDropDownOpen,</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Path</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">=IsChecked}" /&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Window.Resources</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Grid</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Grid.RowDefinitions</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">RowDefinition</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Height</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="Auto"/&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">RowDefinition</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Height</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="*"/&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Grid.RowDefinitions</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">CheckBox</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Content</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="IsDropDownOpen"</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Name</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="cb_IsDropDownOpen" /&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 2">&nbsp; </SPAN>&lt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">toolkit</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">:</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">DatePicker</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> Grid.Row</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="1"<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Name</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="datePicker"<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpMiddle><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Style</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="{</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">StaticResource</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"> DatePickerStyle</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">}" /&gt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 12pt; BACKGROUND: #f6f5f0; mso-add-space: auto" class=codesampleCxSpLast><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;/</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes">Grid</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;</SPAN><SPAN style="LINE-HEIGHT: 125%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p></o:p></SPAN></P></DIV>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri></FONT></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>I’ve setup a style on the DatePicker where I’ve bound a CheckBox.IsChecked DP to the DatePicker.IsDropDownOpen DP.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you click on the CheckBox, the popup opens as expected.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you take a look at the BaseValueSource on IsDropDownOpen it will read Style.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>However, as soon as you close the popup, the binding does not work anymore which is expected since a local value is set on IsDropDownOpen.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Summary<o:p></o:p></FONT></FONT></B></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>To make it really short and sweet, setting dependency properties to local values in internal operations of a control can lead to the dreaded control local values bug.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I’m sure you’re next question is, how can this be prevented?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Well, I will be doing a follow-up post on what has been added in dev10 to easily prevent this bug so stay tuned!</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri><STRONG>UPDATE</STRONG>: Check out the follow up post <A href="https://blogs.msdn.com/vinsibal/archive/2009/05/21/the-control-local-values-bug-solution-and-new-wpf-4-0-related-apis.aspx" mce_href="https://blogs.msdn.com/vinsibal/archive/2009/05/21/the-control-local-values-bug-solution-and-new-wpf-4-0-related-apis.aspx">here</A>.</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>WPFToolkit March 2009 Release and new WPF Themes!</title>
      <link>https://docs.microsoft.com/archive/blogs/vinsibal/wpftoolkit-march-2009-release-and-new-wpf-themes</link>
      <pubDate>Fri, 20 Mar 2009 08:36:00 GMT</pubDate>
      <dc:creator><![CDATA[Vincent Sibal - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vinsibal/2009/03/20/wpftoolkit-march-2009-release-and-new-wpf-themes/</guid>
      <description><![CDATA[An updated version of the WPFToolkit has been released today.&nbsp; This includes&nbsp;some high...]]></description>
      <content:encoded><![CDATA[<P>An updated version of the <A href="https://www.codeplex.com/wpf" mce_href="https://www.codeplex.com/wpf">WPFToolkit</A> has been released today.&nbsp; This includes&nbsp;some high pri&nbsp;bug fixes which are briefly described in the <A href="https://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24969" mce_href="https://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24969">downloads</A> tab.&nbsp; As a reminder, if you have any questions or find any issues please use the <A href="https://wpf.codeplex.com/Thread/List.aspx" mce_href="https://wpf.codeplex.com/Thread/List.aspx">Discussion list</A> and the <A href="https://wpf.codeplex.com/WorkItem/List.aspx" mce_href="https://wpf.codeplex.com/WorkItem/List.aspx">Issue Tracker</A>.&nbsp; Enjoy!</P>
<P>Also,&nbsp;a new set of WPF Themes has also been released in the <A href="https://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962" mce_href="https://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962">WPF Futures</A> section.&nbsp; This is a collection of 9 themes that are also found in the <A href="https://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%203" mce_href="https://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%203">Silverlight Toolkit</A>.</P>]]></content:encoded>
    </item>
  </channel>
</rss>