<?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: How can I update an explicit binding within a template?</title>
	<atom:link href="http://bea.stollnitz.com/blog/?feed=rss2&#038;p=41" rel="self" type="application/rss+xml" />
	<link>http://bea.stollnitz.com/blog/?p=41</link>
	<description>on Silverlight and WPF</description>
	<lastBuildDate>Mon, 02 Aug 2010 17:57:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-170151</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Fri, 20 Nov 2009 02:12:43 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-170151</guid>
		<description>Hi KD,

Yes, there have been some improvements in this scenario. There are is now the &quot;Binding Groups&quot; feature which allows the user to more easily submit a group of explicit bindings. You can read more about this feature in &lt;a href=&quot;http://blogs.msdn.com/vinsibal/archive/2008/08/11/wpf-3-5-sp1-feature-bindinggroups-with-item-level-validation.aspx&quot; rel=&quot;nofollow&quot;&gt;Vincent&#039;s blog&lt;/a&gt;.

Bea</description>
		<content:encoded><![CDATA[<p>Hi KD,</p>
<p>Yes, there have been some improvements in this scenario. There are is now the &#8220;Binding Groups&#8221; feature which allows the user to more easily submit a group of explicit bindings. You can read more about this feature in <a href="http://blogs.msdn.com/vinsibal/archive/2008/08/11/wpf-3-5-sp1-feature-bindinggroups-with-item-level-validation.aspx" rel="nofollow">Vincent&#8217;s blog</a>.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KD</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-163625</link>
		<dc:creator>KD</dc:creator>
		<pubDate>Tue, 15 Sep 2009 08:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-163625</guid>
		<description>Hi, your post is two years old and I was wondering if something changed in the latest version of WPF to simplify the explicit issues described here (you wrote &quot;We would like to make it easier, but unfortunately we will not be able to make that happen in the next release&quot;), just wondering what are the latest news.</description>
		<content:encoded><![CDATA[<p>Hi, your post is two years old and I was wondering if something changed in the latest version of WPF to simplify the explicit issues described here (you wrote &#8220;We would like to make it easier, but unfortunately we will not be able to make that happen in the next release&#8221;), just wondering what are the latest news.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-394</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Fri, 21 Sep 2007 00:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-394</guid>
		<description>It&#039;s a cool trick. Thanks for pointing it out.
I&#039;m glad that OneWayToSource is useful after all.

Bea</description>
		<content:encoded><![CDATA[<p>It&#8217;s a cool trick. Thanks for pointing it out.<br />
I&#8217;m glad that OneWayToSource is useful after all.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-386</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 19 Sep 2007 23:48:11 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-386</guid>
		<description>Hi Rob,

RelativeSource bindings will be re-evaluated every time there is a change in layout. More specifically, RelativeSource bindings are evaluated 1) when SetBinding is called, 2) by a method that is queued in the dispatcher at a priority lower than layout, and 3) every time we get a layout changed event. The relative binding source may not exist while layout is still happening, but once layout settles, the source will be there. We will retry evaluating the binding until that happens. You can find the code for this in the AttachToContext method of BindingExpression.

Let me know if this helps.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Rob,</p>
<p>RelativeSource bindings will be re-evaluated every time there is a change in layout. More specifically, RelativeSource bindings are evaluated 1) when SetBinding is called, 2) by a method that is queued in the dispatcher at a priority lower than layout, and 3) every time we get a layout changed event. The relative binding source may not exist while layout is still happening, but once layout settles, the source will be there. We will retry evaluating the binding until that happens. You can find the code for this in the AttachToContext method of BindingExpression.</p>
<p>Let me know if this helps.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-375</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 19 Sep 2007 06:25:14 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-375</guid>
		<description>Hi RN,

At first sight, both the first and second methods seem to be equally good. The first method has the slight advantage that you don&#039;t need to know the name of the DataTemplate. The third method won&#039;t work anytime you&#039;re looking for an element within the DataTemplate, like in this sample. If you&#039;re looking for something within the ControlTemplate, the third method is the best, quickest way to get a handle to the element.

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi RN,</p>
<p>At first sight, both the first and second methods seem to be equally good. The first method has the slight advantage that you don&#8217;t need to know the name of the DataTemplate. The third method won&#8217;t work anytime you&#8217;re looking for an element within the DataTemplate, like in this sample. If you&#8217;re looking for something within the ControlTemplate, the third method is the best, quickest way to get a handle to the element.</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-373</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 19 Sep 2007 06:08:50 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-373</guid>
		<description>Yes, you&#039;re completely right. I changed the code in the sample attached and in the blog post.
Great catch, and thanks a lot for letting me know!

Bea</description>
		<content:encoded><![CDATA[<p>Yes, you&#8217;re completely right. I changed the code in the sample attached and in the blog post.<br />
Great catch, and thanks a lot for letting me know!</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-372</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 19 Sep 2007 05:47:08 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-372</guid>
		<description>Hi Alex,

It should be possible to do what you&#039;re asking by using BeginInvoke. There are a few things that you will want to keep in mind:

1. Don&#039;t do a BeginInvoke with a priority higher than what is necessary. This may cause your app to slow down.
2. Don&#039;t forget to lock your data.
3. Don&#039;t call BeginInvoke before the previous BeginInvoke call has been process from the queue - this can also cause delays. You can write some code like the following:

// this code should be called by the worker thread
lock(this)
{
  ...store data items for later use by the UI thread
  if(this.dispatcherOperation == null)
  {
    this.dispatcherOperation = Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, ...this.MyFunction...);
  }
} 

// this will be called in the UI thread
private void MyFunction(...)
{
  lock(this)
  {
    ...add items to the ListView
    this.dispatcherOperation = null;
  }
}


Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi Alex,</p>
<p>It should be possible to do what you&#8217;re asking by using BeginInvoke. There are a few things that you will want to keep in mind:</p>
<p>1. Don&#8217;t do a BeginInvoke with a priority higher than what is necessary. This may cause your app to slow down.<br />
2. Don&#8217;t forget to lock your data.<br />
3. Don&#8217;t call BeginInvoke before the previous BeginInvoke call has been process from the queue &#8211; this can also cause delays. You can write some code like the following:</p>
<p>// this code should be called by the worker thread<br />
lock(this)<br />
{<br />
  &#8230;store data items for later use by the UI thread<br />
  if(this.dispatcherOperation == null)<br />
  {<br />
    this.dispatcherOperation = Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, &#8230;this.MyFunction&#8230;);<br />
  }<br />
} </p>
<p>// this will be called in the UI thread<br />
private void MyFunction(&#8230;)<br />
{<br />
  lock(this)<br />
  {<br />
    &#8230;add items to the ListView<br />
    this.dispatcherOperation = null;<br />
  }<br />
}</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-370</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 19 Sep 2007 01:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-370</guid>
		<description>Hi PeterG,

If I understand correctly, you are asking for a way to call UpdateSource on all bindings below a certain element in the tree. We&#039;ve talked about that on the data binding team, but never got around to doing it. Our idea was to add a Bindings collection to certain elements, which would contain all the Bindings associated with child elements in the same namescope. To update all bindings of a particular user control, you would simply have to get the Bindings collection for that control, enumerate through all BindingExpressions and call UpdateSource() on them.

Unfortunately I very much doubt that this feature will be included in our next release, given our current planning - unless of course, there is a lot of customer demand. So scream if you would like to see us implement that :)

Until then, we need to continue doing that manually... :(

Thanks a lot for your feedback!!

Bea</description>
		<content:encoded><![CDATA[<p>Hi PeterG,</p>
<p>If I understand correctly, you are asking for a way to call UpdateSource on all bindings below a certain element in the tree. We&#8217;ve talked about that on the data binding team, but never got around to doing it. Our idea was to add a Bindings collection to certain elements, which would contain all the Bindings associated with child elements in the same namescope. To update all bindings of a particular user control, you would simply have to get the Bindings collection for that control, enumerate through all BindingExpressions and call UpdateSource() on them.</p>
<p>Unfortunately I very much doubt that this feature will be included in our next release, given our current planning &#8211; unless of course, there is a lot of customer demand. So scream if you would like to see us implement that :)</p>
<p>Until then, we need to continue doing that manually&#8230; :(</p>
<p>Thanks a lot for your feedback!!</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-364</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Tue, 18 Sep 2007 18:48:38 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-364</guid>
		<description>Hi Ryan,

Yes, it does make sense. Unfortunately that is the current behavior of ObjectDataProvider and I can&#039;t think of a simple workaround to call the method for each item. A &lt;a href=&quot;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2075847&amp;SiteID=1&quot; rel=&quot;nofollow&quot;&gt;similar question&lt;/a&gt; has been answered in the WPF forum recently. 

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi Ryan,</p>
<p>Yes, it does make sense. Unfortunately that is the current behavior of ObjectDataProvider and I can&#8217;t think of a simple workaround to call the method for each item. A <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2075847&#038;SiteID=1" rel="nofollow">similar question</a> has been answered in the WPF forum recently. </p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=41&#038;cpage=1#comment-360</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Tue, 18 Sep 2007 17:20:23 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=41#comment-360</guid>
		<description>Hi John,

Please see my reply to Tony B, below. I modified this sample to behave the way you guys want - you can find my code &lt;a href=&quot;http://www.beacosta.com/BlogComments/31UpdateExplicit.zip&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi John,</p>
<p>Please see my reply to Tony B, below. I modified this sample to behave the way you guys want &#8211; you can find my code <a href="http://www.beacosta.com/BlogComments/31UpdateExplicit.zip" rel="nofollow">here</a>.</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
</channel>
</rss>
