<?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: Dynamically Switch WPF DataTemplate</title>
	<atom:link href="http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html</link>
	<description>Real World .NET Methods, Tricks, and Examples</description>
	<lastBuildDate>Fri, 30 Jul 2010 16:13:40 -0400</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: AvA</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-9955</link>
		<dc:creator>AvA</dc:creator>
		<pubDate>Tue, 16 Feb 2010 15:59:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-9955</guid>
		<description>Window window = System.Windows.Application.Current.MainWindow

The problem is, that my MainWindow is NOT the window where I have my comboBox in. My mainWindow opens another window, say winXXX; this window is the active window and has the comboBox in it. 
My DataTemplateSelector still selects the MainWindow.
How can I change this?</description>
		<content:encoded><![CDATA[<p>Window window = System.Windows.Application.Current.MainWindow</p>
<p>The problem is, that my MainWindow is NOT the window where I have my comboBox in. My mainWindow opens another window, say winXXX; this window is the active window and has the comboBox in it.<br />
My DataTemplateSelector still selects the MainWindow.<br />
How can I change this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-9909</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Wed, 11 Nov 2009 14:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-9909</guid>
		<description>That&#039;s great Mauro!  Make sure you download the project and check out the Trigger approach: since I wrote that article, I&#039;ve come to find it is easier to implement in most situations.</description>
		<content:encoded><![CDATA[<p>That&#8217;s great Mauro!  Make sure you download the project and check out the Trigger approach: since I wrote that article, I&#8217;ve come to find it is easier to implement in most situations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mauro</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-9908</link>
		<dc:creator>Mauro</dc:creator>
		<pubDate>Wed, 11 Nov 2009 10:46:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-9908</guid>
		<description>Quoting: --&quot; I had previously read about DataTemplateSelector, but I was under the mistaken impression that it was used only in the context of state changes for the bound object. &quot;-- ... --&quot; that I could access the Application state as well, which means that I could pull basically any information I needed, such as the currently selected item in my ListBox.&quot;--

that was the point! and your solution is a great idea, that solved my problem. Thanks!</description>
		<content:encoded><![CDATA[<p>Quoting: &#8211;&#8221; I had previously read about DataTemplateSelector, but I was under the mistaken impression that it was used only in the context of state changes for the bound object. &#8220;&#8211; &#8230; &#8211;&#8221; that I could access the Application state as well, which means that I could pull basically any information I needed, such as the currently selected item in my ListBox.&#8221;&#8211;</p>
<p>that was the point! and your solution is a great idea, that solved my problem. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ursri</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-9894</link>
		<dc:creator>ursri</dc:creator>
		<pubDate>Wed, 07 Oct 2009 11:41:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-9894</guid>
		<description>This works fine with WPF win application. But the same code fails for Sketchflow
Can anyone throw some light on how to set datatemplate to selected list item in Sketchflow screen?</description>
		<content:encoded><![CDATA[<p>This works fine with WPF win application. But the same code fails for Sketchflow<br />
Can anyone throw some light on how to set datatemplate to selected list item in Sketchflow screen?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-9883</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Wed, 09 Sep 2009 13:43:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-9883</guid>
		<description>Thanks Shimmy, the pure XAML approach is mentioned above in the section titled &quot;An Alternative Approach&quot;.  Please feel free to post some code if you have something better.</description>
		<content:encoded><![CDATA[<p>Thanks Shimmy, the pure XAML approach is mentioned above in the section titled &#8220;An Alternative Approach&#8221;.  Please feel free to post some code if you have something better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shimmy</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-9882</link>
		<dc:creator>Shimmy</dc:creator>
		<pubDate>Wed, 09 Sep 2009 02:46:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-9882</guid>
		<description>There is a better way to do it with Triggers in pure Xaml</description>
		<content:encoded><![CDATA[<p>There is a better way to do it with Triggers in pure Xaml</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-3065</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Mon, 12 Jan 2009 23:49:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-3065</guid>
		<description>I tried that, but container is actually a ContentPresenter and not the containing element.  And when I tried to find the ContentPresenter&#039;s parent, it too was listed as a ContentPresenter.  When I issued &quot;var p = ItemsControl.ItemsControlFromItemContainer(container);&quot;, p was returned null.

It does seem to me that there should be a way to make this work without hard coding any values, but I&#039;m not sure what it would be (other than storing the hard coded strings as variables).</description>
		<content:encoded><![CDATA[<p>I tried that, but container is actually a ContentPresenter and not the containing element.  And when I tried to find the ContentPresenter&#8217;s parent, it too was listed as a ContentPresenter.  When I issued &#8220;var p = ItemsControl.ItemsControlFromItemContainer(container);&#8221;, p was returned null.</p>
<p>It does seem to me that there should be a way to make this work without hard coding any values, but I&#8217;m not sure what it would be (other than storing the hard coded strings as variables).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Molon Labe</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-3064</link>
		<dc:creator>Molon Labe</dc:creator>
		<pubDate>Mon, 12 Jan 2009 22:15:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-3064</guid>
		<description>Ah, nevermind. The item is already the Person. You need to get the selected person. You could still use ItemsControl.ItemsControlFromItemContainer(container) to get to the ListBox. 

Also, ListBoxItem (the container) has an IsSelected property which you could test for instead of retrieving the SelectedItem from the ListBox.</description>
		<content:encoded><![CDATA[<p>Ah, nevermind. The item is already the Person. You need to get the selected person. You could still use ItemsControl.ItemsControlFromItemContainer(container) to get to the ListBox. </p>
<p>Also, ListBoxItem (the container) has an IsSelected property which you could test for instead of retrieving the SelectedItem from the ListBox.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Molon Labe</title>
		<link>http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html/comment-page-1#comment-3019</link>
		<dc:creator>Molon Labe</dc:creator>
		<pubDate>Sat, 10 Jan 2009 00:43:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=199#comment-3019</guid>
		<description>Maybe the container argument has the information you seek out of the ListBox? Wouldn&#039;t CType(container,ListBoxItem).DataContext be the Person object bound to the ListBoxItem? Then you wouldn&#039;t have to dig through Application to find a hardcoded element name.</description>
		<content:encoded><![CDATA[<p>Maybe the container argument has the information you seek out of the ListBox? Wouldn&#8217;t CType(container,ListBoxItem).DataContext be the Person object bound to the ListBoxItem? Then you wouldn&#8217;t have to dig through Application to find a hardcoded element name.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
