<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>xaml ninja &#187; PathListBox</title>
	<atom:link href="http://blogs.xamlninja.com/category/pathlistbox/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.xamlninja.com</link>
	<description>xaml ninja moves</description>
	<lastBuildDate>Tue, 10 Jan 2012 19:46:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PathListBox Adventures &#8211; radial layout</title>
		<link>http://blogs.xamlninja.com/silverlight/pathlistbox-adventures-radial-layout</link>
		<comments>http://blogs.xamlninja.com/silverlight/pathlistbox-adventures-radial-layout#comments</comments>
		<pubDate>Mon, 29 Mar 2010 11:13:45 +0000</pubDate>
		<dc:creator>rich</dc:creator>
				<category><![CDATA[Blend]]></category>
		<category><![CDATA[PathListBox]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Xaml]]></category>

		<guid isPermaLink="false">http://blogs.xamlninja.com/?p=224</guid>
		<description><![CDATA[The PathListBox ROCKS, if you have not heard of this control before then checkout Christians blog for more details and also his session at mix 10. The PathListBox solves some of the tricky issues related to creating custom panels for a ListBox or ItemsControl. Previously when we need custom layout of visual elements inside of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.xamlninja.com/wp-content/uploads/2010/03/RadialPanel.png" rel="shadowbox[sbpost-224];player=img;" target="_blank"><img style="margin: 5px auto; display: block; float: none; border-width: 0px;" title="RadialPanel" src="http://blogs.xamlninja.com/wp-content/uploads/2010/03/RadialPanel_thumb.png" border="0" alt="RadialPanel" width="632" height="484" /></a></p>
<p>The PathListBox ROCKS, if you have not heard of this control before then checkout <a href="http://electricbeach.org/" target="_blank">Christians</a> blog for more details and also his session at mix 10. The PathListBox solves some of the tricky issues related to creating custom panels for a ListBox or ItemsControl. Previously when we need custom layout of visual elements inside of these controls we would typically create a custom Panel and crank C# code and some positioning logic to layout the elements as we needed. However, with the introduction of the PathListBox we nolonger have to resort to building a panel and thus lowers the barrier to entry for designers who want to create custom layouts without having to be reliant on a developer to build the panel.</p>
<p>To get going with the PathListBox I wanted to create an simple Silverlight app which pulled back some results from digg, this is something which I have done in the past to illustrate the basics of MVVM in my session from PDC. While on the topic of MVVM its great to see that we now have an MVVM template inside of Blend that we can use. In this post I am not going to talk about the MVVM templates as I have only started out with them and so to give a comparison would not be justifiable at this stage, but I will posting an article when I have it straighten out in my head.</p>
<p>So for this first adventure I created a new MVVM Silverlight application and added a Model and a Service folder. As we already have the code for the digg service and the model created <em>I copied these classes and moved them into their respective folders in the project. Open up the VM that has been added into the project and we can see that it implements INPC. The other thing to notice is that the constructor in parameter less, which is unlike my VM’s where I would normally inject an interface. So for the purposes of this example i am going to new up the interface inside of the constructor.</em></p>
<p>Ok so there are 3 steps that we need to perform in order to recreate the radial panel visual layout that is illustrated above. First we need to create our path on the design surface and then add the PathListBox to the design surface and associate the path with the PathListBox. As with a regular ItemsControl or ListBox we need to bind it to a list of items which in this case is our collection of FeedItems. Blend 4 Beta does quite alot of work for free, you will notice it has created the DataTemplate, ItemContainerStyle and ItemPanelTemplate which is rather nice. So here we start our 3 Steps and each step is associated with the templates and style.</p>
<p>First select the DataTemplate of the PathListBox either from the crumb bar or from right clicking in the objects panel. What we need to do here is add a ChangePropertyAction which fires when we LeftMouseButtonDown on to the DataTemplate so that we can set a flag on the data bound object so that it gets removed from the current list and added to second list. Once we have added this we need to change the RotateTransform on the StackPanel to 90.</p>
<p><a href="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxDatatemplateChangePropertyAction.png" rel="shadowbox[sbpost-224];player=img;"><img style="margin: 5px; display: inline; float: none; border-width: 0px;" title="PathListBoxDatatemplateChangePropertyAction" src="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxDatatemplateChangePropertyAction_thumb.png" border="0" alt="PathListBoxDatatemplateChangePropertyAction" width="644" height="476" /></a></p>
<p>Navigate back to the PathListBox and this time we want to edit the orientation on the items on the path so that they are OrientToPath and check the Wrap Items checkbox.</p>
<p><a href="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxSettings.png" rel="shadowbox[sbpost-224];player=img;"><img style="display: inline; border-width: 0px;" title="PathListBoxSettings" src="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxSettings_thumb.png" border="0" alt="PathListBoxSettings" width="584" height="484" /></a></p>
<p>The second step is to move into our ItemContainerStyle for the PathListBox and change the VSM states so that we have a nice transition for the items when they are loaded and unloaded. With the release of Blend 4 Beta a new set of states have been added to the ListBoxItem. PathListBoxItem subclasses ListBoxItem and so we have the ability to modify the transitions for the BeforeLoaded and AfterLoaded states. For these I</p>
<p><a href="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxStyleLayoutStates.png" rel="shadowbox[sbpost-224];player=img;"><img style="margin: 5px; display: inline; border-width: 0px;" title="PathListBoxStyleLayoutStates" src="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxStyleLayoutStates_thumb.png" border="0" alt="PathListBoxStyleLayoutStates" width="440" height="154" align="left" /></a></p>
<p>simply changed the Opacity on the root element so that we can have a simple fade in type transition. Next we need to change the length of the transition in this case to 0.3 seconds, and change the easing function to your desired choice. The other changes I made here was to enable the Fluid Layout and turned on the design time layout transitions so that you can see your transitions during design time. Navigate back to the PathListBox.</p>
<p>The final piece to the puzzle is to change the ItemPanelTemplate. Edit the template either via the assets panel or the crumb bar. Here we are looking to add  the FluidMoveBehavior on to our PathPanel which will be responsible for providing the animation effect for moving items between the two PathListBox’s.</p>
<p><a href="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxItemsPanelTemplateFluidMoveBehavior.png" rel="shadowbox[sbpost-224];player=img;"><img style="margin: 5px auto; display: block; float: none; border-width: 0px;" title="PathListBoxItemsPanelTemplateFluidMoveBehavior" src="http://blogs.xamlninja.com/wp-content/uploads/2010/03/PathListBoxItemsPanelTemplateFluidMoveBehavior_thumb.png" border="0" alt="PathListBoxItemsPanelTemplateFluidMoveBehavior" width="644" height="446" /></a> The important things to note here include; we have selected the Children option from the AppliesTo dropdown as we want this particular FluidMoveBehavior to effect all the items in the ListBox; I changed the duration and also the easing functions that I wanted to use; I also selected the DataContext option from the Tag dropdown as I want to capture the data object associated with the item that is being animated. Navigate back to the PathListBox……</p>
<p>And we are done.</p>
<p>3 simple steps for you to add a radial panel layout into your project.</p>
<ol>
<li>Change the data template so that it can handle a user interaction</li>
<li>Change the ItemContainerStyle BeforeLoaded and AfterLoaded States</li>
<li>Change the ItemPanelTemplate by adding in the FluidMoveBehavior</li>
</ol>
<p>We also used ChangePropertyAction to manipulate the data in our collections exposed by the VM, and  we  used the FluidMoveBehavior to animate selected items from one PathListBox to another. The ability to do this without having to write any C# is a great step forwards, it does have some consequences but the advantages from my prospective outweigh the disadvantages.</p>
<p>The next thing that I want to do is animate each individual PathListBoxItem depending on where they are on the Path associated with the PathListBox.</p>
<p>All the code for this example you can find on my SkyDrive Folder.</p>
<p>&lt;iframe title =&#8221;Preview&#8221; scrolling=&#8221;no&#8221; marginheight=&#8221;0&#8243; marginwidth=&#8221;0&#8243; frameborder=&#8221;0&#8243; style=&#8221;width:98px;height:115px;padding:0;background-color:#fcfcfc;&#8221; src=&#8221;http://cid-118ee1873690fc1d.skydrive.live.com/embedicon.aspx/Silverlight4/MvvmApplication3.zip&#8221;&gt;&lt;/iframe&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.xamlninja.com/silverlight/pathlistbox-adventures-radial-layout/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

