<?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 should I data bind a Polygon&#8217;s Points to a data source? &#8211; Part III</title>
	<atom:link href="http://bea.stollnitz.com/blog/?feed=rss2&#038;p=37" rel="self" type="application/rss+xml" />
	<link>http://bea.stollnitz.com/blog/?p=37</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=37&#038;cpage=1#comment-355</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Tue, 18 Sep 2007 06:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-355</guid>
		<description>Hi Nat,

Yes, it could have memory leaks - my code doesn&#039;t ever remove anything from the dictionary. In this scenario, I&#039;m not really sure how you would know when it is safe to remove an entry from the dictionary.

Thanks for pointing that out,
Bea</description>
		<content:encoded><![CDATA[<p>Hi Nat,</p>
<p>Yes, it could have memory leaks &#8211; my code doesn&#8217;t ever remove anything from the dictionary. In this scenario, I&#8217;m not really sure how you would know when it is safe to remove an entry from the dictionary.</p>
<p>Thanks for pointing that out,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nat</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-73</link>
		<dc:creator>Nat</dc:creator>
		<pubDate>Tue, 31 Jul 2007 09:25:55 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-73</guid>
		<description>Hi,

Nice article. Will it have memory leak problem? PointCollection seems to keep forever in synthetic singleton converter object.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Nice article. Will it have memory leak problem? PointCollection seems to keep forever in synthetic singleton converter object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-71</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Sun, 05 Nov 2006 19:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-71</guid>
		<description>Hi,

Regarding your comment about using ItemsControl... what solution exactly do you have in mind? 

I can think of one way to use ItemsControl: in each DataTemplate there would be a Line element with X2 and Y2 data bound to the current point and X1 and Y1 bound to RelativeSource=PreviousData. This would be terribly inneficient because instead of one element (Polyline) we would have at least two elements per line (the ContentControl generated by the ItemsControl for each item, plus the Line inside the DataTemplate). 

Unless you have in mind a more efficient way of using ItemsControl to solve this problem, I strongly discourage using it.

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Regarding your comment about using ItemsControl&#8230; what solution exactly do you have in mind? </p>
<p>I can think of one way to use ItemsControl: in each DataTemplate there would be a Line element with X2 and Y2 data bound to the current point and X1 and Y1 bound to RelativeSource=PreviousData. This would be terribly inneficient because instead of one element (Polyline) we would have at least two elements per line (the ContentControl generated by the ItemsControl for each item, plus the Line inside the DataTemplate). </p>
<p>Unless you have in mind a more efficient way of using ItemsControl to solve this problem, I strongly discourage using it.</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-72</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Sun, 05 Nov 2006 18:02:59 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-72</guid>
		<description>Hi Kent,

Regarding your comment on UpdateTarget, it is true that it doesn&#039;t work in your scenario. When you call UpdateTarget, we check for the source object, and update the target only if the object is different. In your scenario, since the collection is still the same (we&#039;re really comparing the pointer), we don&#039;t do anything. So, basically, UpdateTarget will only work when the actual source object is replaced by some other different object.

I agree with you that this is not very intuitive and that we should do something about it. I&#039;ve added this to the list of discussions to have when planning for the next version.

In the meantime, to achieve the behavior you want, you can simply add the following line instead of the UpdateTarget: 

lb.Items.Refresh();

I&#039;ve uploaded a simple application that does this here.

Let me know if this fixes your problem.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Kent,</p>
<p>Regarding your comment on UpdateTarget, it is true that it doesn&#8217;t work in your scenario. When you call UpdateTarget, we check for the source object, and update the target only if the object is different. In your scenario, since the collection is still the same (we&#8217;re really comparing the pointer), we don&#8217;t do anything. So, basically, UpdateTarget will only work when the actual source object is replaced by some other different object.</p>
<p>I agree with you that this is not very intuitive and that we should do something about it. I&#8217;ve added this to the list of discussions to have when planning for the next version.</p>
<p>In the meantime, to achieve the behavior you want, you can simply add the following line instead of the UpdateTarget: </p>
<p>lb.Items.Refresh();</p>
<p>I&#8217;ve uploaded a simple application that does this here.</p>
<p>Let me know if this fixes your problem.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-69</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sat, 04 Nov 2006 12:45:16 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-69</guid>
		<description>Hello Bea,

Thanks for your post. I believe there are reasons you didn&#039;t use ItemsControl for data binding in your project. Of course, complexity of code will be more if not the same. But I would appreciate if you can clarify.</description>
		<content:encoded><![CDATA[<p>Hello Bea,</p>
<p>Thanks for your post. I believe there are reasons you didn&#8217;t use ItemsControl for data binding in your project. Of course, complexity of code will be more if not the same. But I would appreciate if you can clarify.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kent boogaart</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-68</link>
		<dc:creator>Kent boogaart</dc:creator>
		<pubDate>Fri, 03 Nov 2006 11:35:17 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-68</guid>
		<description>Hi Beatriz,

I couldn&#039;t find a suggestion box so I hope you don&#039;t mind me making one here.

I&#039;d like to see how to use the BindingExpressionBase.UpdateTarget() method. I have bound a ListBox to a non-notifying collection. 

When I add an item to the collection the UI understandably does not update. I figured all I would have to do is get the binding expression (via BindingOperations) and call UpdateTarget. However, that does not do anything. The only way I have been able to get the UI to update is to set the DataContext to null and then back to the original object.

Thanks,
Kent</description>
		<content:encoded><![CDATA[<p>Hi Beatriz,</p>
<p>I couldn&#8217;t find a suggestion box so I hope you don&#8217;t mind me making one here.</p>
<p>I&#8217;d like to see how to use the BindingExpressionBase.UpdateTarget() method. I have bound a ListBox to a non-notifying collection. </p>
<p>When I add an item to the collection the UI understandably does not update. I figured all I would have to do is get the binding expression (via BindingOperations) and call UpdateTarget. However, that does not do anything. The only way I have been able to get the UI to update is to set the DataContext to null and then back to the original object.</p>
<p>Thanks,<br />
Kent</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-70</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Fri, 03 Nov 2006 04:07:09 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-70</guid>
		<description>Hi Sheva,

I&#039;m really glad to see my blog posts as the starting point for other blog posts. I like to see other people thinking about the same problems, and finding different approaches.

Your solution is great, but I have two comments about it:

- Your PointCollectionView intermediate object needs to know that the source data is of the type PolygonItem. A truly reusable solution should work for any source. This is of course not an issue if you always bind to the same source type in your application, and if you don&#039;t intend to reuse this code in other scenarios.

- I don&#039;t see a reason why the Points property needs to be a DP. The source of a binding can be a simple CLR property.

Thanks for thinking of this problem and for coming up with such a great solution.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Sheva,</p>
<p>I&#8217;m really glad to see my blog posts as the starting point for other blog posts. I like to see other people thinking about the same problems, and finding different approaches.</p>
<p>Your solution is great, but I have two comments about it:</p>
<p>- Your PointCollectionView intermediate object needs to know that the source data is of the type PolygonItem. A truly reusable solution should work for any source. This is of course not an issue if you always bind to the same source type in your application, and if you don&#8217;t intend to reuse this code in other scenarios.</p>
<p>- I don&#8217;t see a reason why the Points property needs to be a DP. The source of a binding can be a simple CLR property.</p>
<p>Thanks for thinking of this problem and for coming up with such a great solution.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-66</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 03 Nov 2006 02:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-66</guid>
		<description>Ummmm it seems using the hash code as the key would be very bad if you had a collision. You would either get an exception when you tried to add the duplicate key or you would end up overwriting the value with a completely different object just because the hashcodes happened to collide.</description>
		<content:encoded><![CDATA[<p>Ummmm it seems using the hash code as the key would be very bad if you had a collision. You would either get an exception when you tried to add the duplicate key or you would end up overwriting the value with a completely different object just because the hashcodes happened to collide.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sheva</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-67</link>
		<dc:creator>Sheva</dc:creator>
		<pubDate>Thu, 02 Nov 2006 12:35:57 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-67</guid>
		<description>Hi Bea, I just post my approach to polygon binding on my blog, you can take a glance at it &lt;a href=&quot;http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!466.entry&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

Sheva</description>
		<content:encoded><![CDATA[<p>Hi Bea, I just post my approach to polygon binding on my blog, you can take a glance at it <a href="http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!466.entry" rel="nofollow">here</a>.</p>
<p>Sheva</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=37&#038;cpage=1#comment-65</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 01 Nov 2006 22:44:02 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=37#comment-65</guid>
		<description>Hi Sheva,

That&#039;s a very good point. Thanks a lot for your feedback.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Sheva,</p>
<p>That&#8217;s a very good point. Thanks a lot for your feedback.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
</channel>
</rss>
