<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Silverlight Attached Properties: Binding.UpdateSourceTrigger.PropertyChanged</title>
	<atom:link href="http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/feed" rel="self" type="application/rss+xml" />
	<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged</link>
	<description>Sharing our knowledge</description>
	<lastBuildDate>Thu, 19 Jan 2012 06:22:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Keith</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-237977</link>
		<dc:creator>Keith</dc:creator>
		<pubDate>Tue, 29 Jun 2010 23:22:48 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-237977</guid>
		<description>Ugh... I guess it&#039;s the HTML killing it...  Should inherit from generic Behavior where T is TextBox.</description>
		<content:encoded><![CDATA[<p>Ugh&#8230; I guess it&#8217;s the HTML killing it&#8230;  Should inherit from generic Behavior where T is TextBox.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-237975</link>
		<dc:creator>Keith</dc:creator>
		<pubDate>Tue, 29 Jun 2010 23:21:50 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-237975</guid>
		<description>Sorry, error above due to trying to &quot;fix&quot; formatting.  Should inherit from : Behavior not just Behavior.</description>
		<content:encoded><![CDATA[<p>Sorry, error above due to trying to &#8220;fix&#8221; formatting.  Should inherit from : Behavior not just Behavior.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-237974</link>
		<dc:creator>Keith</dc:creator>
		<pubDate>Tue, 29 Jun 2010 23:20:43 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-237974</guid>
		<description>Here it is as a behavior:

public class PropertyChangedBindingBehavior : Behavior
{
    protected override void OnAttached()
    {
        base.OnAttached();

        AssociatedObject.TextChanged += new TextChangedEventHandler(AssociatedObject_TextChanged);
    }

    protected override void OnDetaching()
    {
        base.OnDetaching();

        AssociatedObject.TextChanged -= new TextChangedEventHandler(AssociatedObject_TextChanged);
    }

    void AssociatedObject_TextChanged(object sender, TextChangedEventArgs e)
    {
        AssociatedObject.GetBindingExpression(TextBox.TextProperty).UpdateSource();
    }
}

You need a reference to System.Windows.Interactivity.

Then in XAML:

    &lt;i&gt;    
&lt;/i&gt;


i is the System.Windows.Interactivity, beh is your namepsace for the PropertyChangedBindingBehavior.


I think it&#039;s nicer than the attached property since you can unwire from the TextChanged.</description>
		<content:encoded><![CDATA[<p>Here it is as a behavior:</p>
<p>public class PropertyChangedBindingBehavior : Behavior<br />
{<br />
    protected override void OnAttached()<br />
    {<br />
        base.OnAttached();</p>
<p>        AssociatedObject.TextChanged += new TextChangedEventHandler(AssociatedObject_TextChanged);<br />
    }</p>
<p>    protected override void OnDetaching()<br />
    {<br />
        base.OnDetaching();</p>
<p>        AssociatedObject.TextChanged -= new TextChangedEventHandler(AssociatedObject_TextChanged);<br />
    }</p>
<p>    void AssociatedObject_TextChanged(object sender, TextChangedEventArgs e)<br />
    {<br />
        AssociatedObject.GetBindingExpression(TextBox.TextProperty).UpdateSource();<br />
    }<br />
}</p>
<p>You need a reference to System.Windows.Interactivity.</p>
<p>Then in XAML:</p>
<p>    <i><br />
</i></p>
<p>i is the System.Windows.Interactivity, beh is your namepsace for the PropertyChangedBindingBehavior.</p>
<p>I think it&#8217;s nicer than the attached property since you can unwire from the TextChanged.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karin</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-195419</link>
		<dc:creator>Karin</dc:creator>
		<pubDate>Mon, 07 Sep 2009 09:07:41 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-195419</guid>
		<description>Thanks a lot for your article! This is exactly what I was looking for. I just replaced the part that changes the focus by a call to the UpdateSource method of the binding expression:

if ((bool)e.NewValue)
{
	textBox.TextChanged += (s, arg) =&gt;
	{
		textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
	};
}</description>
		<content:encoded><![CDATA[<p>Thanks a lot for your article! This is exactly what I was looking for. I just replaced the part that changes the focus by a call to the UpdateSource method of the binding expression:</p>
<p>if ((bool)e.NewValue)<br />
{<br />
	textBox.TextChanged += (s, arg) =&gt;<br />
	{<br />
		textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();<br />
	};<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dennis</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-192683</link>
		<dc:creator>dennis</dc:creator>
		<pubDate>Wed, 19 Aug 2009 14:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-192683</guid>
		<description>Hi,

I am just curious? does XAML on silverlight doesnt have any
UpdateSourceTrigger on binding? say UpdateSourceTrigger=PropertyChanged...

Why do you need to get the parent control?
and why do loop on visual tree to get the parent control?

I think there is a simple way to get the parent control using
XAML and no need for code behind..</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am just curious? does XAML on silverlight doesnt have any<br />
UpdateSourceTrigger on binding? say UpdateSourceTrigger=PropertyChanged&#8230;</p>
<p>Why do you need to get the parent control?<br />
and why do loop on visual tree to get the parent control?</p>
<p>I think there is a simple way to get the parent control using<br />
XAML and no need for code behind..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blackjack2150</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-190641</link>
		<dc:creator>blackjack2150</dc:creator>
		<pubDate>Tue, 04 Aug 2009 07:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-190641</guid>
		<description>Hi.
Thanks for this post. It works fine for me, but I still feel a bit awkward knowing how it actually does.
I&#039;m currently working with Silverlighlt 3 and Prism and I can&#039;t help notice the paradox: we use this separation paterns (MVVM for me)in order to keep the code clear and easy to test, modify, etc, but in order to make it actually work, there are a lot of dirty hacks that must be implemented, some with unpredictible side effects. The ideas are great, but the technology is still lacking...</description>
		<content:encoded><![CDATA[<p>Hi.<br />
Thanks for this post. It works fine for me, but I still feel a bit awkward knowing how it actually does.<br />
I&#8217;m currently working with Silverlighlt 3 and Prism and I can&#8217;t help notice the paradox: we use this separation paterns (MVVM for me)in order to keep the code clear and easy to test, modify, etc, but in order to make it actually work, there are a lot of dirty hacks that must be implemented, some with unpredictible side effects. The ideas are great, but the technology is still lacking&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremiah Morrill</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-190066</link>
		<dc:creator>Jeremiah Morrill</dc:creator>
		<pubDate>Thu, 30 Jul 2009 17:12:53 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-190066</guid>
		<description>I was using this method for a minute (so thanks for getting me out of a jam!), but then I found a _cleaner_ way to implement, that is compatible with SL3.

        private static void OnUpdateSourceTriggerChanged(DependencyObject d, 
                                                         DependencyPropertyChangedEventArgs e)
        {
            var textBox = d as TextBox;

            if (textBox == null)
                return;

            KeyEventHandler textChanged = (s, arg) =&gt;
            {
                BindingExpression bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty);

                bindingExpression.UpdateSource();
            };

            if ((bool)e.NewValue)
            {
                textBox.KeyDown -= textChanged;
            }

            if ((bool)e.NewValue)
            {
                textBox.KeyDown += textChanged;
            }
        }</description>
		<content:encoded><![CDATA[<p>I was using this method for a minute (so thanks for getting me out of a jam!), but then I found a _cleaner_ way to implement, that is compatible with SL3.</p>
<p>        private static void OnUpdateSourceTriggerChanged(DependencyObject d,<br />
                                                         DependencyPropertyChangedEventArgs e)<br />
        {<br />
            var textBox = d as TextBox;</p>
<p>            if (textBox == null)<br />
                return;</p>
<p>            KeyEventHandler textChanged = (s, arg) =&gt;<br />
            {<br />
                BindingExpression bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty);</p>
<p>                bindingExpression.UpdateSource();<br />
            };</p>
<p>            if ((bool)e.NewValue)<br />
            {<br />
                textBox.KeyDown -= textChanged;<br />
            }</p>
<p>            if ((bool)e.NewValue)<br />
            {<br />
                textBox.KeyDown += textChanged;<br />
            }<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Claudius Huber</title>
		<link>http://michaelsync.net/2009/06/10/silverlight-attached-properties-bindingupdatesourcetriggerpropertychanged/comment-page-1#comment-187530</link>
		<dc:creator>Thomas Claudius Huber</dc:creator>
		<pubDate>Fri, 17 Jul 2009 12:07:26 +0000</pubDate>
		<guid isPermaLink="false">http://michaelsync.net/?p=1303#comment-187530</guid>
		<description>Hi Michael,

great post. I&#039;ve another solution that doesn&#039;t need the focus trick. Take a look at my blog: http://www.thomasclaudiushuber.com/blog/2009/07/17/here-it-is-the-updatesourcetrigger-for-propertychanged-in-silverlight/</description>
		<content:encoded><![CDATA[<p>Hi Michael,</p>
<p>great post. I&#8217;ve another solution that doesn&#8217;t need the focus trick. Take a look at my blog: <a href="http://www.thomasclaudiushuber.com/blog/2009/07/17/here-it-is-the-updatesourcetrigger-for-propertychanged-in-silverlight/" rel="nofollow">http://www.thomasclaudiushuber.com/blog/2009/07/17/here-it-is-the-updatesourcetrigger-for-propertychanged-in-silverlight/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

