<?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: ItemsControl:  &#039;P&#039; is for Panel</title>
	<atom:link href="http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/feed/" rel="self" type="application/rss+xml" />
	<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/</link>
	<description>Drinking (and serving) the WPF Kool-Aid since 2002</description>
	<lastBuildDate>Mon, 30 Aug 2010 18:54:01 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dr. WPF</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-270</link>
		<dc:creator>Dr. WPF</dc:creator>
		<pubDate>Tue, 19 May 2009 22:45:39 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-270</guid>
		<description>Hi Max,&lt;br&gt;&lt;br&gt;It does sound like a good scenario for a custom panel. You are correct that a panel has no innate concept of selection, however, there is no reason you cannot define the concept of &quot;CenteredChild&quot;. Your layout logic has to place the children around some focal child, right?&lt;br&gt;&lt;br&gt;When you use the panel as an items host in a Selector, you can simply keep the CenteredChild in sync with the selected item.&lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;-dw</description>
		<content:encoded><![CDATA[<p>Hi Max,</p>
<p>It does sound like a good scenario for a custom panel. You are correct that a panel has no innate concept of selection, however, there is no reason you cannot define the concept of &#8220;CenteredChild&#8221;. Your layout logic has to place the children around some focal child, right?</p>
<p>When you use the panel as an items host in a Selector, you can simply keep the CenteredChild in sync with the selected item.</p>
<p>Cheers,<br />-dw</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Palmer</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-269</link>
		<dc:creator>Max Palmer</dc:creator>
		<pubDate>Tue, 19 May 2009 16:39:57 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-269</guid>
		<description>Hi,&lt;br&gt;&lt;br&gt;I want to write a control that behaves like the Windows Media Centre menu. Essentially, it&#039;s a carousel type control where the selected item is always in a fixed vertical location and selecting an item scrolls the list so that the item moves to the selected position. I thought that this might be a job for a custom panel, given it can control the arrangement of the items. However, I have read that the panel does not know / care about which item is selected in it&#039;s children, so this seems to be the wrong approach. Is this the case?&lt;br&gt;&lt;br&gt;Any ideas as to what might be a better solution? &lt;br&gt;&lt;br&gt;Max</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I want to write a control that behaves like the Windows Media Centre menu. Essentially, it&#8217;s a carousel type control where the selected item is always in a fixed vertical location and selecting an item scrolls the list so that the item moves to the selected position. I thought that this might be a job for a custom panel, given it can control the arrangement of the items. However, I have read that the panel does not know / care about which item is selected in it&#8217;s children, so this seems to be the wrong approach. Is this the case?</p>
<p>Any ideas as to what might be a better solution? </p>
<p>Max</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr. WPF</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-268</link>
		<dc:creator>Dr. WPF</dc:creator>
		<pubDate>Fri, 15 May 2009 04:23:26 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-268</guid>
		<description>Hi Arnaud,&lt;br&gt;&lt;br&gt;I think you might be hitting a bug that I discovered about a year ago. (I provided a repro to Microsoft and they are aware of the problem in the underlying panel code, but I don&#039;t know if a fix made it into 3.5 SP1 or not.)&lt;br&gt;&lt;br&gt;If its the same problem, you can work around the issue with the following hack. Override OnVisualChildrenChanged() and add the following code:&lt;br&gt;&lt;br&gt;base.OnVisualChildrenChanged(visualAdded, visualRemoved);&lt;br&gt;if (VisualChildrenCount &gt; 0)&lt;br&gt;{&lt;br&gt;&#160;&#160;&#160;&#160;// force internal notion of z-state to be invalidated&lt;br&gt;&#160;&#160;&#160;&#160;UIElement firstChild = GetVisualChild(0) as UIElement;&lt;br&gt;&#160;&#160;&#160;&#160;if (firstChild != null)&lt;br&gt;&#160;&#160;&#160;&#160;{&lt;br&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Panel.SetZIndex(firstChild, Panel.GetZIndex(firstChild) == 0 ? 1 : 0);&lt;br&gt;&#160;&#160;&#160;&#160;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;This changes the z-index of the first child via GetVisualChild(0) (rather than using the InternalChildren collection). This will reset some internal flags so that the z-order is actually respected during the next render.&lt;br&gt;&lt;br&gt;Note that changing the zIndex on this first child should be okay, since you are most likely updating it to the correct value in your arrange pass. If necessary, you can change the value and then immediately set it back to the desired value.&lt;br&gt;&lt;br&gt;Hope this helps!&lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;-dw</description>
		<content:encoded><![CDATA[<p>Hi Arnaud,</p>
<p>I think you might be hitting a bug that I discovered about a year ago. (I provided a repro to Microsoft and they are aware of the problem in the underlying panel code, but I don&#8217;t know if a fix made it into 3.5 SP1 or not.)</p>
<p>If its the same problem, you can work around the issue with the following hack. Override OnVisualChildrenChanged() and add the following code:</p>
<p>base.OnVisualChildrenChanged(visualAdded, visualRemoved);<br />if (VisualChildrenCount > 0)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;// force internal notion of z-state to be invalidated<br />&nbsp;&nbsp;&nbsp;&nbsp;UIElement firstChild = GetVisualChild(0) as UIElement;<br />&nbsp;&nbsp;&nbsp;&nbsp;if (firstChild != null)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Panel.SetZIndex(firstChild, Panel.GetZIndex(firstChild) == 0 ? 1 : 0);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}</p>
<p>This changes the z-index of the first child via GetVisualChild(0) (rather than using the InternalChildren collection). This will reset some internal flags so that the z-order is actually respected during the next render.</p>
<p>Note that changing the zIndex on this first child should be okay, since you are most likely updating it to the correct value in your arrange pass. If necessary, you can change the value and then immediately set it back to the desired value.</p>
<p>Hope this helps!</p>
<p>Cheers,<br />-dw</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arnaud</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-267</link>
		<dc:creator>Arnaud</dc:creator>
		<pubDate>Thu, 14 May 2009 15:49:45 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-267</guid>
		<description>I built a custom Panel for a ListBox that displays items like a &quot;carousel&quot;.&lt;br&gt;It is 2D and displays item like if it was 3D.&lt;br&gt;I use Panel.SetZIndex() on children to manage Z-Index.&lt;br&gt;All is working well when I scroll the listbox : all items are moving correctly, etc ...&lt;br&gt;BUT when I Add or Remove an item from the ObservableCollection which is binded to the Listbox, Measure and arrange are called, Z-Index are correct (Debug.Print is helpfull), but they are not taking into account into the rendering !?!?&lt;br&gt;Is there a method I should launch to force the Z-Index to be took into account ?&lt;br&gt;I tried lots of things, I read all I could on the web ... you are my last hope :-)&lt;br&gt;&lt;br&gt;Have you already faced this problem ?</description>
		<content:encoded><![CDATA[<p>I built a custom Panel for a ListBox that displays items like a &#8220;carousel&#8221;.<br />It is 2D and displays item like if it was 3D.<br />I use Panel.SetZIndex() on children to manage Z-Index.<br />All is working well when I scroll the listbox : all items are moving correctly, etc &#8230;<br />BUT when I Add or Remove an item from the ObservableCollection which is binded to the Listbox, Measure and arrange are called, Z-Index are correct (Debug.Print is helpfull), but they are not taking into account into the rendering !?!?<br />Is there a method I should launch to force the Z-Index to be took into account ?<br />I tried lots of things, I read all I could on the web &#8230; you are my last hope <img src='http://drwpf.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Have you already faced this problem ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr. WPF</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-265</link>
		<dc:creator>Dr. WPF</dc:creator>
		<pubDate>Fri, 13 Feb 2009 05:38:49 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-265</guid>
		<description>Hi rwb.&lt;br&gt;&lt;br&gt;It definitely sounds like a good candidate for a custom panel. You could have an attached property for both the start time and the duration. The panel would layout its children based on the values of those attached properties.&lt;br&gt;&lt;br&gt;Hopefully that&#039;s enough info to get you started. :-)&lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;-dw</description>
		<content:encoded><![CDATA[<p>Hi rwb.</p>
<p>It definitely sounds like a good candidate for a custom panel. You could have an attached property for both the start time and the duration. The panel would layout its children based on the values of those attached properties.</p>
<p>Hopefully that&#8217;s enough info to get you started. <img src='http://drwpf.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Cheers,<br />-dw</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rwb</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-264</link>
		<dc:creator>rwb</dc:creator>
		<pubDate>Wed, 11 Feb 2009 23:05:20 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-264</guid>
		<description>OK. I want to write a customized listbox that represents a bar graph of sorts. Each bar will represent an execution time for one of many events. I want the bar height to represent a scaled value relating to the execution time for the item AND the scale I set for the entire listbox. Prior to assigning the data to the listbox for presentation I plan to determine the best scale value to use. If the listbox is resized I expect to have the bar sizes adjust accordingly. I feel I&#039;m right &#039;on the edge&#039; of being able to do this myself, but I could sure use some assistance. Any thoughts?&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;rwb</description>
		<content:encoded><![CDATA[<p>OK. I want to write a customized listbox that represents a bar graph of sorts. Each bar will represent an execution time for one of many events. I want the bar height to represent a scaled value relating to the execution time for the item AND the scale I set for the entire listbox. Prior to assigning the data to the listbox for presentation I plan to determine the best scale value to use. If the listbox is resized I expect to have the bar sizes adjust accordingly. I feel I&#8217;m right &#8216;on the edge&#8217; of being able to do this myself, but I could sure use some assistance. Any thoughts?</p>
<p>Thanks,<br />rwb</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-263</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Sat, 29 Nov 2008 14:57:58 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-263</guid>
		<description>wonderful posts, i really love them from my heart, in my job, they give me a more lovely understanding in WPF, Thanks.</description>
		<content:encoded><![CDATA[<p>wonderful posts, i really love them from my heart, in my job, they give me a more lovely understanding in WPF, Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr. WPF</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-262</link>
		<dc:creator>Dr. WPF</dc:creator>
		<pubDate>Sat, 15 Nov 2008 14:57:58 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-262</guid>
		<description>Hi Deepak,&lt;br&gt;&lt;br&gt;In general, if you are doing this in code by waiting on containers to be generated, then you are probably going about it the wrong way. It would be much better to adapt your view model to support an IsSelected property and use a binding in the view to bind the checkbox&#039;s IsChecked state to IsSelected in the view model. Then you never have to directly muck with view objects and the code becomes quite elegant.&lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;-dw</description>
		<content:encoded><![CDATA[<p>Hi Deepak,</p>
<p>In general, if you are doing this in code by waiting on containers to be generated, then you are probably going about it the wrong way. It would be much better to adapt your view model to support an IsSelected property and use a binding in the view to bind the checkbox&#8217;s IsChecked state to IsSelected in the view model. Then you never have to directly muck with view objects and the code becomes quite elegant.</p>
<p>Cheers,<br />-dw</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak Makhija</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-261</link>
		<dc:creator>Deepak Makhija</dc:creator>
		<pubDate>Thu, 06 Nov 2008 12:38:41 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-261</guid>
		<description>Hi Dr. WPF,&lt;br&gt;&lt;br&gt;Firstly I must say it&#039;s a very nice article which gives insight picture :). &lt;br&gt;&lt;br&gt;I am stuck at one point in WPF.&lt;br&gt;&lt;br&gt;I have one drop down say DropDown1, on the basis of it&#039;s change event, another drop down say DropDown2 is getting populated.&lt;br&gt;After populating the data from DropDown2 I want to select the first checkbox item in the dropdown2. &lt;br&gt;I have put the first item selection code in ItemContainerGenerator_StatusChanged event but&lt;br&gt;Unfortunately Item Container status is in notstarted mode :(.&lt;br&gt;&lt;br&gt;Could you please suggest how to solve this ?&lt;br&gt;&lt;br&gt;Here is the sample code :&lt;br&gt;&lt;br&gt; protected void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)&lt;br&gt; {&lt;br&gt; if (uxTransactionSubTypeMultiSelection.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)&lt;br&gt; {&lt;br&gt; uxTransactionSubTypeMultiSelection.ItemContainerGenerator.StatusChanged -= new EventHandler(ItemContainerGenerator_StatusChanged);&lt;br&gt; uxTransactionSubTypeMultiSelection.SetSelectAllSelected(true);&lt;br&gt; }&lt;br&gt; }</description>
		<content:encoded><![CDATA[<p>Hi Dr. WPF,</p>
<p>Firstly I must say it&#8217;s a very nice article which gives insight picture <img src='http://drwpf.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . </p>
<p>I am stuck at one point in WPF.</p>
<p>I have one drop down say DropDown1, on the basis of it&#8217;s change event, another drop down say DropDown2 is getting populated.<br />After populating the data from DropDown2 I want to select the first checkbox item in the dropdown2. <br />I have put the first item selection code in ItemContainerGenerator_StatusChanged event but<br />Unfortunately Item Container status is in notstarted mode <img src='http://drwpf.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .</p>
<p>Could you please suggest how to solve this ?</p>
<p>Here is the sample code :</p>
<p> protected void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)<br /> {<br /> if (uxTransactionSubTypeMultiSelection.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)<br /> {<br /> uxTransactionSubTypeMultiSelection.ItemContainerGenerator.StatusChanged -= new EventHandler(ItemContainerGenerator_StatusChanged);<br /> uxTransactionSubTypeMultiSelection.SetSelectAllSelected(true);<br /> }<br /> }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr. WPF</title>
		<link>http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/comment-page-1/#comment-260</link>
		<dc:creator>Dr. WPF</dc:creator>
		<pubDate>Tue, 01 Jul 2008 06:39:40 +0000</pubDate>
		<guid isPermaLink="false">http://drwpf.com/blog/?p=28#comment-260</guid>
		<description>Hey Josh!  Excellent question.  :)&lt;br&gt;&lt;br&gt;There is really no &quot;elegant&quot; solution for this type of scenario, but there are certainly some approaches that will work.  Typically, rather than create a generic, reusable panel for this type of layout, I will create a UserControl (or if this is for a panel that will be the items host for an ItemsControl, I might create a custom ItemsControl with a well known template).  At that point, it is safe to make assumptions about the visual tree that will be helpful in arranging the children in the panel.&lt;br&gt;&lt;br&gt;For example, if you create a control that contains a ScrollViewer, which, in turn, contains your custom panel, then your custom panel can base its layout algorithm on the ActualHeight of the ScrollViewer (rather than the constraint passed to MeasureOverride).  You will need a binding on the ActualWidth property of the ScrollViewer to determine when to invalidate arrange for your panel.  This incurs an extra layout pass, but it is relatively performant.&lt;br&gt;&lt;br&gt;Note that the same approach could be used within a standalone panel, but it becomes arguably more hacky because the panel is checking to see if its visual parent is a ScrollViewer and in that case, it is using the ActualHeight of the ScrollViewer when arranging its children.&lt;br&gt;&lt;br&gt;Hope this helps!&lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;-dw</description>
		<content:encoded><![CDATA[<p>Hey Josh!  Excellent question.  <img src='http://drwpf.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>There is really no &quot;elegant&quot; solution for this type of scenario, but there are certainly some approaches that will work.  Typically, rather than create a generic, reusable panel for this type of layout, I will create a UserControl (or if this is for a panel that will be the items host for an ItemsControl, I might create a custom ItemsControl with a well known template).  At that point, it is safe to make assumptions about the visual tree that will be helpful in arranging the children in the panel.</p>
<p>For example, if you create a control that contains a ScrollViewer, which, in turn, contains your custom panel, then your custom panel can base its layout algorithm on the ActualHeight of the ScrollViewer (rather than the constraint passed to MeasureOverride).  You will need a binding on the ActualWidth property of the ScrollViewer to determine when to invalidate arrange for your panel.  This incurs an extra layout pass, but it is relatively performant.</p>
<p>Note that the same approach could be used within a standalone panel, but it becomes arguably more hacky because the panel is checking to see if its visual parent is a ScrollViewer and in that case, it is using the ActualHeight of the ScrollViewer when arranging its children.</p>
<p>Hope this helps!</p>
<p>Cheers,<br />-dw</p>
]]></content:encoded>
	</item>
</channel>
</rss>
