<?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 do I display items in an ItemsControl using different templates?</title>
	<atom:link href="http://bea.stollnitz.com/blog/?feed=rss2&#038;p=16" rel="self" type="application/rss+xml" />
	<link>http://bea.stollnitz.com/blog/?p=16</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=16&#038;cpage=1#comment-171519</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Mon, 30 Nov 2009 18:05:02 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-171519</guid>
		<description>That works too.</description>
		<content:encoded><![CDATA[<p>That works too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sergey</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-171498</link>
		<dc:creator>Sergey</dc:creator>
		<pubDate>Mon, 30 Nov 2009 13:45:24 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-171498</guid>
		<description>Bea, thanks for the reply, but I have chosen to use shader effect instead of bitmap conversion. My scenario was to gray button&#039;s image if mouse is not over it.

Sergey</description>
		<content:encoded><![CDATA[<p>Bea, thanks for the reply, but I have chosen to use shader effect instead of bitmap conversion. My scenario was to gray button&#8217;s image if mouse is not over it.</p>
<p>Sergey</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-170265</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Fri, 20 Nov 2009 21:24:45 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-170265</guid>
		<description>Hi Geoff,

The behavior you describe is by design and it was implemented for performance reasons.
If you want to have the DataTemplate be re-evaluated, you can add a handler for property changes. In this handler, you add code that determines the new DataTemplate and sets it explicitly.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Geoff,</p>
<p>The behavior you describe is by design and it was implemented for performance reasons.<br />
If you want to have the DataTemplate be re-evaluated, you can add a handler for property changes. In this handler, you add code that determines the new DataTemplate and sets it explicitly.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-157420</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Mon, 27 Jul 2009 00:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-157420</guid>
		<description>Hi Sergey,

This scenario was never fixed in WPF, unfortunately. 

However, you should be able to work around it with a converter, as you mention. This is how you can do it:

        &lt;Image Source=&quot;{Binding ElementName=tb, Path=Text, Converter={StaticResource imageConverter}}&quot; /&gt;

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FormatConvertedBitmap fcb = new FormatConvertedBitmap();
            fcb.BeginInit();
            fcb.Source = new BitmapImage(new Uri((string)value));
            fcb.EndInit();
            return fcb;
        }

Let me know if this works for you.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Sergey,</p>
<p>This scenario was never fixed in WPF, unfortunately. </p>
<p>However, you should be able to work around it with a converter, as you mention. This is how you can do it:</p>
<p>        &lt;Image Source=&#8221;{Binding ElementName=tb, Path=Text, Converter={StaticResource imageConverter}}&#8221; /&gt;</p>
<p>        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)<br />
        {<br />
            FormatConvertedBitmap fcb = new FormatConvertedBitmap();<br />
            fcb.BeginInit();<br />
            fcb.Source = new BitmapImage(new Uri((string)value));<br />
            fcb.EndInit();<br />
            return fcb;<br />
        }</p>
<p>Let me know if this works for you.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sergey Galich</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-152130</link>
		<dc:creator>Sergey Galich</dc:creator>
		<pubDate>Thu, 25 Jun 2009 10:07:15 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-152130</guid>
		<description>hey Bea, it&#039;s 2009 already, do you know if there are any chance to use FormatConvertedBitmap with data binding? I tried to work around with value converters, but that doesn&#039;t work either. The only solution I can imagine now is to move toward effects, but this is something i would like to avoid atm.</description>
		<content:encoded><![CDATA[<p>hey Bea, it&#8217;s 2009 already, do you know if there are any chance to use FormatConvertedBitmap with data binding? I tried to work around with value converters, but that doesn&#8217;t work either. The only solution I can imagine now is to move toward effects, but this is something i would like to avoid atm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-288</link>
		<dc:creator>Geoff</dc:creator>
		<pubDate>Sun, 12 Aug 2007 12:58:36 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-288</guid>
		<description>Hi there, I have tried using the DataTemplateSelector but it only seems to work on the initial binding to the collection. When I changed a property the propertychanged event is sent but the datatemplate selector is never hit again. Any ideas?</description>
		<content:encoded><![CDATA[<p>Hi there, I have tried using the DataTemplateSelector but it only seems to work on the initial binding to the collection. When I changed a property the propertychanged event is sent but the datatemplate selector is never hit again. Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-287</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Sun, 05 Mar 2006 03:29:05 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-287</guid>
		<description>Manny,

Currently you can not bind to those properties, although they are DPs. 

Notice that CroppedBitmap implements ISupportInitialize. In its implementation of this interface, it restricts the Source property to be set between calling BeginInit() and EndInit(). An exception is thrown if Source is not set between these calls, or if it&#039;s set outside of these calls. This was done this way to improve our perf. Unfortunately, this a problem for data binding because we don&#039;t have the value ready during this initialization.

It&#039;s unlikely that this behavior will change for V1, but this scenario will not be forgotten when we discuss work for future versions of Avalon.

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Manny,</p>
<p>Currently you can not bind to those properties, although they are DPs. </p>
<p>Notice that CroppedBitmap implements ISupportInitialize. In its implementation of this interface, it restricts the Source property to be set between calling BeginInit() and EndInit(). An exception is thrown if Source is not set between these calls, or if it&#8217;s set outside of these calls. This was done this way to improve our perf. Unfortunately, this a problem for data binding because we don&#8217;t have the value ready during this initialization.</p>
<p>It&#8217;s unlikely that this behavior will change for V1, but this scenario will not be forgotten when we discuss work for future versions of Avalon.</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manny</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-286</link>
		<dc:creator>Manny</dc:creator>
		<pubDate>Fri, 03 Mar 2006 18:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-286</guid>
		<description>Hello Beatriz, 

I have modified your examples to try to databind Source values and SourceRect values for a FormatConvertedBitmap
and a CroppedBitmap (below) in a datatemplate. However, when I do so I get exceptions about not being able to set the Source and SourceRect values. Is it possible to databind those properties?

FormatConvertedBitmap x:Name=&quot;masterSource&quot; Source=&quot;{Binding Path=Filename}&quot;
DestinationFormat=&quot;gray4&quot;

CroppedBitmap Source=&quot;{Binding Path=Filename}&quot; SourceRect=&quot;{Binding Path=CropRext}&quot;


Thanks,
Manny</description>
		<content:encoded><![CDATA[<p>Hello Beatriz, </p>
<p>I have modified your examples to try to databind Source values and SourceRect values for a FormatConvertedBitmap<br />
and a CroppedBitmap (below) in a datatemplate. However, when I do so I get exceptions about not being able to set the Source and SourceRect values. Is it possible to databind those properties?</p>
<p>FormatConvertedBitmap x:Name=&#8221;masterSource&#8221; Source=&#8221;{Binding Path=Filename}&#8221;<br />
DestinationFormat=&#8221;gray4&#8243;</p>
<p>CroppedBitmap Source=&#8221;{Binding Path=Filename}&#8221; SourceRect=&#8221;{Binding Path=CropRext}&#8221;</p>
<p>Thanks,<br />
Manny</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-285</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Sun, 12 Feb 2006 15:10:52 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-285</guid>
		<description>Hi Barry,

I&#039;ve replied to your post in the forums. Let me know if I got your scenario right.

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi Barry,</p>
<p>I&#8217;ve replied to your post in the forums. Let me know if I got your scenario right.</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry</title>
		<link>http://bea.stollnitz.com/blog/?p=16&#038;cpage=1#comment-284</link>
		<dc:creator>Barry</dc:creator>
		<pubDate>Sun, 12 Feb 2006 07:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=16#comment-284</guid>
		<description>Hi Beatrize,

I apologise if this is a little off-topic but you seem to be the most knowledgable person around with regards to data binding and a problem I am having is data binding-related.

I have posted a question on MSDN&#039;s WPF forum to which I have had no reply. I find this a little worrying because what I want to do should be quite straightforward.

Would you be kind enough to look at my posting? If so it&#039;s at,

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=247378&amp;SiteID=1</description>
		<content:encoded><![CDATA[<p>Hi Beatrize,</p>
<p>I apologise if this is a little off-topic but you seem to be the most knowledgable person around with regards to data binding and a problem I am having is data binding-related.</p>
<p>I have posted a question on MSDN&#8217;s WPF forum to which I have had no reply. I find this a little worrying because what I want to do should be quite straightforward.</p>
<p>Would you be kind enough to look at my posting? If so it&#8217;s at,</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=247378&#038;SiteID=1" rel="nofollow">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=247378&#038;SiteID=1</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
