<?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 propagate changes across threads?</title>
	<atom:link href="http://bea.stollnitz.com/blog/?feed=rss2&#038;p=34" rel="self" type="application/rss+xml" />
	<link>http://bea.stollnitz.com/blog/?p=34</link>
	<description>on Silverlight and WPF</description>
	<lastBuildDate>Thu, 22 Jul 2010 20:56:04 +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=34&#038;cpage=1#comment-91</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Tue, 11 Sep 2007 05:20:58 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-91</guid>
		<description>Hi YesKay,

I am able to animate a Button&#039;s Width inside a ListView. You can find my sample &lt;a href=&quot;http://www.beacosta.com/BlogComments/12AnimateButtonListView.zip&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. Is this what you were trying to do?

Let me know.
Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi YesKay,</p>
<p>I am able to animate a Button&#8217;s Width inside a ListView. You can find my sample <a href="http://www.beacosta.com/BlogComments/12AnimateButtonListView.zip" rel="nofollow">here</a>. Is this what you were trying to do?</p>
<p>Let me know.<br />
Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-104</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 22 Nov 2006 00:24:45 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-104</guid>
		<description>Hi Tony,

There are a few ways you can do that.

1) You can override the metadata of the DPs that affect your new DP and add a change handler that changes your new DP too. However, I can&#039;t get this solution to work with your particular scenario because ActualWidth and ActualHeight are read only. I don&#039;t know if it&#039;s possible to override metadata of read only properties - I had trouble doing that.

2) You can override the PropertyChanged method and, if the DPs passed in the event args are ActualWidth or ActualHeight, you recalculate Center. 

3) You can override OnRenderSizeChanged and recalculate Center within this method. This is the solution I implemented, which you can find &lt;a href=&quot;http://www.beacosta.com/BlogComments/23UpdatableDPs.zip&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

Here is the part of the code that matters:

protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
this.MyCenter = new Point(sizeInfo.NewSize.Width / 2.0, sizeInfo.NewSize.Height / 2.0);
}
Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi Tony,</p>
<p>There are a few ways you can do that.</p>
<p>1) You can override the metadata of the DPs that affect your new DP and add a change handler that changes your new DP too. However, I can&#8217;t get this solution to work with your particular scenario because ActualWidth and ActualHeight are read only. I don&#8217;t know if it&#8217;s possible to override metadata of read only properties &#8211; I had trouble doing that.</p>
<p>2) You can override the PropertyChanged method and, if the DPs passed in the event args are ActualWidth or ActualHeight, you recalculate Center. </p>
<p>3) You can override OnRenderSizeChanged and recalculate Center within this method. This is the solution I implemented, which you can find <a href="http://www.beacosta.com/BlogComments/23UpdatableDPs.zip" rel="nofollow">here</a>.</p>
<p>Here is the part of the code that matters:</p>
<p>protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)<br />
{<br />
base.OnRenderSizeChanged(sizeInfo);<br />
this.MyCenter = new Point(sizeInfo.NewSize.Width / 2.0, sizeInfo.NewSize.Height / 2.0);<br />
}<br />
Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tony</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-103</link>
		<dc:creator>tony</dc:creator>
		<pubDate>Mon, 20 Nov 2006 22:18:53 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-103</guid>
		<description>Bea,
I guess your email box would get full often and quickly if you published it.

But (sigh) that leaves me with no other option but to comment here.

I asked this question in many forums and never got any response so you are my last hope.

Basically, I want to create a new dependency property (DP), the value of which would depend on calculation involving several other DPs (custom or existing). 

For ex. custom Canvas DP called Center would depend on Canvas&#039; existing Top, Left, Width and Height (or ActualWidth and ActualHeight) DPs.

Like: Center.X=Left+ActualWidth/2.0

I want to bind to this new Center DP and be sure that, whatever changes Canvas goes through, dragging, resizing, scaling, rotation, re-layout, ecc. it will always update the target with fresh Center coordinates.

What is the best way to do that without resorting to MultiBinding and Converters (if possible)?</description>
		<content:encoded><![CDATA[<p>Bea,<br />
I guess your email box would get full often and quickly if you published it.</p>
<p>But (sigh) that leaves me with no other option but to comment here.</p>
<p>I asked this question in many forums and never got any response so you are my last hope.</p>
<p>Basically, I want to create a new dependency property (DP), the value of which would depend on calculation involving several other DPs (custom or existing). </p>
<p>For ex. custom Canvas DP called Center would depend on Canvas&#8217; existing Top, Left, Width and Height (or ActualWidth and ActualHeight) DPs.</p>
<p>Like: Center.X=Left+ActualWidth/2.0</p>
<p>I want to bind to this new Center DP and be sure that, whatever changes Canvas goes through, dragging, resizing, scaling, rotation, re-layout, ecc. it will always update the target with fresh Center coordinates.</p>
<p>What is the best way to do that without resorting to MultiBinding and Converters (if possible)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-102</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 15 Nov 2006 21:36:25 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-102</guid>
		<description>Hi Kent,

Sam Bent (from the data team) and I see at least one serious bug in your solution and in Chong&#039;s solution (http://itchong.blogspot.com/2007/01/how-can-i-propagate-changes-across.html). It applies to all operations, but let&#039;s take Insert as an example. Your method inserts the new item into the data structure on the worker thread, then raises the change notifcation on the dispatcher thread (blocking the worker thread until the dispatcher thread is available). So there&#039;s an interval of time where the item has been added, but the dispatcher thread doesn&#039;t know it yet. If the dispatcher thread reads the collection during this interval, it will get the wrong information. This can lead to incorrect display, or even a crash.

The solution in my blog does both the actual insertion and the notification on the dispatcher thread, so it doesn&#039;t have the problem.</description>
		<content:encoded><![CDATA[<p>Hi Kent,</p>
<p>Sam Bent (from the data team) and I see at least one serious bug in your solution and in Chong&#8217;s solution (<a href="http://itchong.blogspot.com/2007/01/how-can-i-propagate-changes-across.html" rel="nofollow">http://itchong.blogspot.com/2007/01/how-can-i-propagate-changes-across.html</a>). It applies to all operations, but let&#8217;s take Insert as an example. Your method inserts the new item into the data structure on the worker thread, then raises the change notifcation on the dispatcher thread (blocking the worker thread until the dispatcher thread is available). So there&#8217;s an interval of time where the item has been added, but the dispatcher thread doesn&#8217;t know it yet. If the dispatcher thread reads the collection during this interval, it will get the wrong information. This can lead to incorrect display, or even a crash.</p>
<p>The solution in my blog does both the actual insertion and the notification on the dispatcher thread, so it doesn&#8217;t have the problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-101</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Fri, 10 Nov 2006 17:10:55 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-101</guid>
		<description>Hi Kent,

Once again, I love seing people thinking about the same issues I think about and coming up with alternative approaches. I&#039;m a big fan of solutions that improve the separation of UI and data - I love the improvements in your solution!

(And btw, yes, it is *SHE* and not he :) )

Bea</description>
		<content:encoded><![CDATA[<p>Hi Kent,</p>
<p>Once again, I love seing people thinking about the same issues I think about and coming up with alternative approaches. I&#8217;m a big fan of solutions that improve the separation of UI and data &#8211; I love the improvements in your solution!</p>
<p>(And btw, yes, it is *SHE* and not he :) )</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kent boogaart</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-100</link>
		<dc:creator>Kent boogaart</dc:creator>
		<pubDate>Thu, 09 Nov 2006 06:59:50 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-100</guid>
		<description>Hi Beatriz,

Great post. I thought you might be interested in my take on the subject: http://kentb.blogspot.com/2006/11/cross-thread-collection-binding-in-wpf.html</description>
		<content:encoded><![CDATA[<p>Hi Beatriz,</p>
<p>Great post. I thought you might be interested in my take on the subject: <a href="http://kentb.blogspot.com/2006/11/cross-thread-collection-binding-in-wpf.html" rel="nofollow">http://kentb.blogspot.com/2006/11/cross-thread-collection-binding-in-wpf.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-99</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sun, 08 Oct 2006 21:15:35 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-99</guid>
		<description>You could also use the Avalon supplied SynchronizationContext from the UI thread to accomplish the Send/Post of worker delegates to the UI thread. I am not sure if it accomplishes much in this situation apart from changing the type of the constructor argument from Dispatcher to SynchronizationContext, eliminating the ability to set priority (it uses Normal priority) and eliminating the kind of ugly Dispatcher.BeginInvoke call. It could gain you a more generic type of collection, one in which constructor arguments could dictate the threading context in which operations occured, so by creating it with the Avalon supplied SynchronizationContext all operations would happen on the UI thread and by supplying a default one all operations would either occur on the invoking thread or on a threadpool thread (depending on if you did a Post or Send).</description>
		<content:encoded><![CDATA[<p>You could also use the Avalon supplied SynchronizationContext from the UI thread to accomplish the Send/Post of worker delegates to the UI thread. I am not sure if it accomplishes much in this situation apart from changing the type of the constructor argument from Dispatcher to SynchronizationContext, eliminating the ability to set priority (it uses Normal priority) and eliminating the kind of ugly Dispatcher.BeginInvoke call. It could gain you a more generic type of collection, one in which constructor arguments could dictate the threading context in which operations occured, so by creating it with the Avalon supplied SynchronizationContext all operations would happen on the UI thread and by supplying a default one all operations would either occur on the invoking thread or on a threadpool thread (depending on if you did a Post or Send).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brett</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-98</link>
		<dc:creator>Brett</dc:creator>
		<pubDate>Sat, 07 Oct 2006 18:03:44 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-98</guid>
		<description>Hi Bea,

Thanks for responding! My thread on the forums still goes unanswered. :-)

Best,

Brett</description>
		<content:encoded><![CDATA[<p>Hi Bea,</p>
<p>Thanks for responding! My thread on the forums still goes unanswered. :-)</p>
<p>Best,</p>
<p>Brett</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-97</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Sat, 07 Oct 2006 02:48:28 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-97</guid>
		<description>Hi Brett,

Welcome back to WPF.
I am not an expert on the parser, but as far as I know there is no escaping mechanism that allows you to do that. I think it&#039;s not possible to do what you want, for V1.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Brett,</p>
<p>Welcome back to WPF.<br />
I am not an expert on the parser, but as far as I know there is no escaping mechanism that allows you to do that. I think it&#8217;s not possible to do what you want, for V1.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brett</title>
		<link>http://bea.stollnitz.com/blog/?p=34&#038;cpage=1#comment-96</link>
		<dc:creator>Brett</dc:creator>
		<pubDate>Thu, 05 Oct 2006 19:34:23 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=34#comment-96</guid>
		<description>Bea,

I&#039;ve been busy working on other parts of .NET 3.0, but I am back on WPF. I&#039;m sorry to pollute your comments, but like Sam I have an off topic question for which I am not able to find an answer (asked on WPF forums with no takers). If you can help, I would greatly appreciate it.

Is there any support for creating DataTemplates where the DataType is generic? Using the MyClass&lt;int&gt; format creates invalid XML, and MyClass`1[[System.Int32, etc.]] seems a bit of a stretch. Is this something that is simply not possible in XAML?

Thanks in advance,

Brett</description>
		<content:encoded><![CDATA[<p>Bea,</p>
<p>I&#8217;ve been busy working on other parts of .NET 3.0, but I am back on WPF. I&#8217;m sorry to pollute your comments, but like Sam I have an off topic question for which I am not able to find an answer (asked on WPF forums with no takers). If you can help, I would greatly appreciate it.</p>
<p>Is there any support for creating DataTemplates where the DataType is generic? Using the MyClass<int> format creates invalid XML, and MyClass`1[[System.Int32, etc.]] seems a bit of a stretch. Is this something that is simply not possible in XAML?</p>
<p>Thanks in advance,</p>
<p>Brett</int></p>
]]></content:encoded>
	</item>
</channel>
</rss>
