<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Ruurd Boeke Enterprise development and technobabble</title>
    <link>http://www.sitechno.com/Blog/</link>
    <description>All about agile, OR-mapping and winfx - yeah baby!</description>
    <language>en-us</language>
    <copyright>Ruurd Boeke</copyright>
    <lastBuildDate>Mon, 27 Apr 2009 16:28:32 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>contact@sitechno.com</managingEditor>
    <webMaster>contact@sitechno.com</webMaster>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=8a472c80-1a8c-4d23-8b3e-c1cadbd4929c</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,8a472c80-1a8c-4d23-8b3e-c1cadbd4929c.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,8a472c80-1a8c-4d23-8b3e-c1cadbd4929c.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=8a472c80-1a8c-4d23-8b3e-c1cadbd4929c</wfw:commentRss>
      <slash:comments>60</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve seen quite a few slideshow controls for Silverlight. Mostly they are either retemplated
listboxes (buying an easy transition effect for free) or custom controls. I’d like
to see how the DomainUpDown control can be used to do a slide show. This post also
takes a more indepth look at TransitioningContentControl and along the way shows how
to retemplate and inherit/extend other controls.
</p>
        <p>
The <a href="http://www.sitechno.com/Blog/DomainUpDown.aspx">DomainUpDown</a> control
allows you to visualize a ‘domain’, which can be anything. In our case, our domain
will consist of UIElements. The <a href="http://www.sitechno.com/Blog/ct.ashx?id=d1845361-f351-478a-8724-c5b5fffb8d06&amp;url=http%3a%2f%2fsilverlight.codeplex.com%2fWiki%2fView.aspx%3ftitle%3dSilverlight%2520Toolkit%2520Overview%2520Part%25201%26ANCHOR%23TransitioningContentControl">TransitionContentControl</a> is
an experimental control that I haven’t featured on this blog yet. It is a ‘convenience’
control, with which I mean to say that the control just takes care of a very common
goal in Silverlight development. In this case, it will react to changes in Content
by transitioning old content out and transitioning new content in. I’ve talked briefly
about the control <a href="http://www.sitechno.com/Blog/SilverlightToolkitMarch2009Released.aspx">here</a>.
</p>
        <p>
By using DomainUpDown (henceforth: DUD), we will get a nice navigation system for
free (up/down arrows) and the option to show our domain in a cyclic way (in other
words, after you reach the end, it will jump to the first item again). Also, we have
the option to allow shortcuts into the domain, by having the user type in the control.
We will disable that though. 
</p>
        <p>
I certainly do not like the default look of the control though, with its big up/down
buttons. So, we have some work ahead of us.
</p>
        <p>
I’ve started out with a new SL2 application, adding references to:
</p>
        <ul>
          <li>
System.Windows.Controls.Toolkit 
</li>
          <li>
System.Windows.Controls.Toolkit.Input 
</li>
          <li>
System.Windows.Controls.Toolkit.Layout 
</li>
        </ul>
        <p>
These are part of the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a>.
</p>
        <p>
I’ve also added a folder called Images and put some images in there. Just making it
easy on myself, I’ve hardcoded those images into the Items collection of my DUD. I
do not want users to be able to type in the DUD, so I set ‘IsEditable’ to false. I
know the images are 300*400, so I even hardcoded the width/height of the control.
I end up with this Xaml:
</p>
        <pre class="brush: xml;">&lt;UserControl
  x:Class="BlogImageSlideshow.Page"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"&gt;
  &lt;Grid
    x:Name="LayoutRoot"
    Background="White"&gt;
    &lt;inputToolkit:DomainUpDown
      Height="300"
      Width="400"
      IsEditable="False"&gt;
      &lt;Image
        Source="Images/3410783929_051d93bc86.jpg" /&gt;
      &lt;Image
        Source="Images/3412190495_4099006101.jpg" /&gt;
      &lt;Image
        Source="Images/3413898641_f975065242.jpg" /&gt;
      &lt;Image
        Source="Images/3414953148_cec704b7b8.jpg" /&gt;
      &lt;Image
        Source="Images/3415344995_730b5cc814.jpg" /&gt;
    &lt;/inputToolkit:DomainUpDown&gt;
  &lt;/Grid&gt;
&lt;/UserControl&gt;</pre>
        <p>
 
</p>
        <p>
When we view the control though, we are in for a surprise:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb.png" width="390" height="304" />
          </a>
        </p>
        <p>
The buttons are way to big, and our image is way too small. This is caused by the
way those buttons are created (with paths, set to scale uniformly). In most situations
that will be exactly what you would like, however, in our case it most definitely
is not. We’ll want to retemplate our control and are going to do that the ‘easy’ way:
through Blend.
</p>
        <p>
Once in Blend, I choose to edit the template of the DUD, which creates a style for
me. The Object tab reveals the following parts of DUD:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_1.png" width="295" height="373" />
          </a>
        </p>
        <p>
        </p>
        <p>
To fix the ugly buttons, let’s repeat the process and retemplate the Spinner (which
is a ButtonSpinner). That ButtonSpinner is responsible for hosting our content (in
the image that is a Grid with two children: ‘Visualization’ and ‘Text’. It is also
responsible for displaying the two buttons. 
</p>
        <p>
Editing the Spinner reveals these objects:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_2.png" width="301" height="347" />
          </a>
        </p>
        <p>
The unnamed [Button] is used to ‘catch’ the mouseclicks that are done on a disabled
button. We don’t need it, so I’ll remove it. Also, I don’t want the buttons on the
right side, but I want the previous button on the left and the next button on the
right. I actually have a great idea: I’ll overlay the buttons and make them transparent.
That way, pressing on the right side of the image will move the slideshow forwards
and pressing on the left side will make it go backwards.
</p>
        <p>
I also retemplated the buttons: removing the usual gradient, but having some overlay
on ‘mouseOver’ to indicate that we can press. Since I’m no designer, I just used a
one white rectangle with an opacity of 0 and a linear gradient opacitymask. On MouseOver,
I will animate the opacity to 30%. The effect is a gradual whitening at the border
of the image.
</p>
        <p>
This is the style for one of the buttons:
</p>
        <pre class="brush: xml;">&lt;Style x:Key="RepeatButtonStyle1" TargetType="RepeatButton"&gt;
    &lt;Setter Property="Background" Value="#FF1F3B53"/&gt;
    &lt;Setter Property="Foreground" Value="#FF000000"/&gt;
    &lt;Setter Property="Padding" Value="3"/&gt;
    &lt;Setter Property="BorderThickness" Value="1"/&gt;
    &lt;Setter Property="BorderBrush"&gt;
        &lt;Setter.Value&gt;
            &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                &lt;GradientStop Color="#FFA3AEB9" Offset="0"/&gt;
                &lt;GradientStop Color="#FF8399A9" Offset="0.375"/&gt;
                &lt;GradientStop Color="#FF718597" Offset="0.375"/&gt;
                &lt;GradientStop Color="#FF617584" Offset="1"/&gt;
            &lt;/LinearGradientBrush&gt;
        &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
    &lt;Setter Property="Template"&gt;
        &lt;Setter.Value&gt;
            &lt;ControlTemplate TargetType="RepeatButton"&gt;
                &lt;Grid x:Name="Root"&gt;
                    &lt;vsm:VisualStateManager.VisualStateGroups&gt;
                        &lt;vsm:VisualStateGroup x:Name="CommonStates"&gt;
                            &lt;vsm:VisualState x:Name="Normal"/&gt;
                            &lt;vsm:VisualState x:Name="MouseOver"&gt;
                                &lt;Storyboard&gt;
                                    &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.3"/&gt;
                                    &lt;/DoubleAnimationUsingKeyFrames&gt;
                                &lt;/Storyboard&gt;
                            &lt;/vsm:VisualState&gt;
                            &lt;vsm:VisualState x:Name="Pressed"&gt;
                                &lt;Storyboard/&gt;
                            &lt;/vsm:VisualState&gt;
                            &lt;vsm:VisualState x:Name="Disabled"&gt;
                                &lt;Storyboard/&gt;
                            &lt;/vsm:VisualState&gt;
                        &lt;/vsm:VisualStateGroup&gt;
                        &lt;vsm:VisualStateGroup x:Name="FocusStates"&gt;
                            &lt;vsm:VisualState x:Name="Focused"&gt;
                                &lt;Storyboard/&gt;
                            &lt;/vsm:VisualState&gt;
                            &lt;vsm:VisualState x:Name="Unfocused"/&gt;
                        &lt;/vsm:VisualStateGroup&gt;
                    &lt;/vsm:VisualStateManager.VisualStateGroups&gt;
                    &lt;Rectangle Height="Auto" Margin="0,0,0,0" VerticalAlignment="Stretch" Stroke="#FF000000" Opacity="0" x:Name="rectangle" Fill="#FFFFFFFF"&gt;
                        &lt;Rectangle.OpacityMask&gt;
                            &lt;LinearGradientBrush EndPoint="-0.015,0.493" StartPoint="0.99,0.497"&gt;
                                &lt;GradientStop Color="#00000000"/&gt;
                                &lt;GradientStop Color="#FFFFFFFF" Offset="1"/&gt;
                            &lt;/LinearGradientBrush&gt;
                        &lt;/Rectangle.OpacityMask&gt;
                    &lt;/Rectangle&gt;
                &lt;/Grid&gt;
            &lt;/ControlTemplate&gt;
        &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
&lt;/Style&gt;</pre>
        <h5>And now for the fun stuff: Animating it!
</h5>
        <p>
Currently the status of the project is that I am able to quickly show a bunch of images
and I can mouse over the image and click to show the next/previous image. We’re now
going to dive into the TransitioningContentControl and use it to create a nice sliding
effect.
</p>
        <p>
First some background: in Silverlight and in WPF, you use a ContentControl to visualize
any type of content you might have. When setting a new content, the ContentControl
will just replace the current visual with a new visual (representing your new content).
It uses a ContentTemplate to determine how to visualize your content. 
<br />
The only feature that TransitioningContentControl adds to this game is an easy way
to start an animation to visualize the actual replacing of content. Although there
are some technical difficulties (more on that later), it is meant as a drop-in replacement
for ContentControl.
</p>
        <p>
The DomainUpDown also uses a ContentControl to show your content. The templatepart
is called ‘Visualization’ and we are going to replace that with a TransitioningContentControl.
All I did was replace the ContentControl tag with TransitioningContentControl in the
template for DomainUpDown. 
</p>
        <p>
Now, here comes the catch: because an element can’t be in the visual tree twice (at
the same time) in SL2 this creates a bit of a problem when using the TCC (TransitioningContentControl)
with FrameworkElements. In SL3 I will solve this quite easily by creating an image
out of the content and using that to ‘transition out’ but in SL2 the only easy work-around
is to not use elements with this control. That is actually quite easy, because we
can use the ContentTemplate to create our elements on the fly. I’ve changed the way
I use DUD as follow:
</p>
        <pre class="brush: xml;">&lt;inputToolkit:DomainUpDown
    Height="300" Width="400"
    IsEditable="False" Style="{StaticResource SlideShowStyle}"&gt;
&lt;inputToolkit:DomainUpDown.ItemTemplate&gt;
  &lt;DataTemplate&gt;
    &lt;Image Source="{Binding}" /&gt;
  &lt;/DataTemplate&gt;
&lt;/inputToolkit:DomainUpDown.ItemTemplate&gt;
&lt;System:String&gt;Images/3410783929_051d93bc86.jpg&lt;/System:String&gt;
&lt;System:String&gt;Images/3412190495_4099006101.jpg&lt;/System:String&gt;
&lt;System:String&gt;Images/3413898641_f975065242.jpg&lt;/System:String&gt;
&lt;System:String&gt;Images/3414953148_cec704b7b8.jpg&lt;/System:String&gt;
&lt;System:String&gt;Images/3415344995_730b5cc814.jpg&lt;/System:String&gt;
&lt;/inputToolkit:DomainUpDown&gt;</pre>
        <p>
Because the TCC actually has a nice default transition, we could call it a day: there
is a nice fade-in/fade-out animation going on. I like it! 
<br />
However, let’s see if we can actually create a slideshow.
</p>
        <p>
To start off, I went ahead and edited the template for TransitioningContentControl.
In Blend3 there seems to be a bug that not the complete template is copied (making
it rather useless). Blend2 works fine though. 
<br />
The inevitable object screenshot shows 
<br /><a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_3.png" width="308" height="227" /></a></p>
        <p>
two ‘presentationSites’. Which enables you to see through my trickery: the only thing
I do when content is being set, is copy the content inside ‘CurrentContentPresentation’
to ‘PreviousContentPresentation’ and start a storyboard. These are the storyboards
that come out of the box:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_10.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_4.png" width="312" height="270" />
          </a>
        </p>
        <p>
Now, I fully expect you to create / add your own transitions here. To do that, you
would go into xaml and add an empty storyboard. At that point you can use the designer
again to style it. However, we’ll be fine by restyling the UpTransition and DownTransition. 
</p>
        <p>
Currently they do a nice fade and rendertransform. That doesn’t work for me though,
so let’s start with the UpTransition, I’d like to have the PreviousContentPresentationSite
move to the left and have the Current come in from the right. 
<br />
That’s pretty easy, I just animated two rendertransforms to do that, not forgetting
to set a nice keyspline for the smooth effect.
</p>
        <p>
Next assignment: we’ll need to let TCC know which transition to use. It has no knowledge
of the concept of up or down or whatever transitions you came up with. 
<br />
To be able to tell TCC which transition to play, I expose a DependencyProperty of
type string. That indicates the exact name of the transition that should be used the
next time the content is changed. 
</p>
        <p>
There are many ways to do this. You could hook into the buttons and set the Transition
manually. I believe the easiest way though, is to inherit from DomainUpDown and add
the functionality yourself:
</p>
        <pre class="brush: csharp;">public class SlidingDomainUpDown : DomainUpDown
{
    private TransitioningContentControl _visualizer;

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();

        _visualizer = GetTemplateChild("Visualization") as TransitioningContentControl;
    }

    protected override void OnDecrement()
    {
        if (_visualizer != null)
        {
            _visualizer.Transition = "DownTransition";
        }
        base.OnDecrement();
    }

    protected override void OnIncrement()
    {

        if (_visualizer != null)
        {
            _visualizer.Transition = "UpTransition";
        }

        base.OnIncrement();
    }
}</pre>
        <p>
 
</p>
        <p>
Interestingly enough, I get asked how to get to templateparts all the time, on the
silverlight.net forums. Well, here you go: the simplest possible example there is.
I hope this is clear!
</p>
        <p>
At this point, everything works fine for me. Except that the effect is horrible! You
see the complete image moving, but you would expect to only see it inside of the frame.
What we need is some clipping. 
<br />
I’m no Blend hero, but I pulled it off by creating a rectangle and right-clicking,
choosing Path/make clipping path. Then I chose the TCC element, called ‘Visualization’
to be the clipping target. It ended up creating this xaml: 
</p>
        <p>
Clip="M0.5,0.5 L395.5,0.5 L395.5,295.5 L0.5,295.5 z"
</p>
        <p>
We’re now at a point that I’m really happy about! The user has some feedback when
he mouses over the image and the effect is quite nice. The user can click too fast
though (while the transition is in motion) and I’d like to disable that:
</p>
        <pre class="brush: csharp;">protected override void OnValueChanging(RoutedPropertyChangingEventArgs&lt;object&gt; e)
{
    base.OnValueChanging(e);

    if (_visualizer != null &amp;&amp; _visualizer.IsTransitioning)
    {
        e.Cancel = true;
    }
}</pre>
        <p>
It would have been nicer to disable the buttons, but this will do for now.
</p>
        <h5>Taking the extra step: adding direct shortcuts
</h5>
        <p>
This is becoming a huge post, but I’m having too much fun. 
<br />
You have seen slideshows that have little indicators on the buttom that allow you
to directly navigate to an image. I’m thinking of the Hulu.com example:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_12.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_5.png" width="385" height="168" />
          </a>
        </p>
        <p>
Let’s create those!
</p>
        <p>
I started by adding a ListBox to the template of our SlidingDomainUpDown control.
I cheated a bit and hardlinked the Items collection to the ItemsSource collection
of that ListBox. 
<br />
Then I went on to restyle the ListBoxItems to show a small preview of our item. Then
I hooked up the ListBox.SelectionChanged event. When the selecteditem changes, I just
set the Value of the DomainUpDown. Obviously, this could have been more elegantly
done by creating a binding between the Value property and the SelectedItem property
of the ListBox.  (oh well, it’s my blog! :) ) 
<br />
I also cheated because I did not spend the time looking at the key handling. The listbox
actually takes care of some of the keyhandling, and I don’t like it. 
</p>
        <p>
I end up with this:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_14.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_6.png" width="355" height="351" />
          </a>
        </p>
        <p>
I set up the transition to be the DefaultTransition (which is a nice fade in/fade
out). So, now the user can slide or go directly to an image. Loving it!
</p>
        <p>
Try it out <a href="http://www.sitechno.com/Silverlight/DUD_TCC/BlogImageSlideshowSource.zip">here</a> and
grab the solution <a href="http://www.sitechno.com/Silverlight/DUD_TCC/TestPage.html">here</a>.
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=8a472c80-1a8c-4d23-8b3e-c1cadbd4929c" />
      </body>
      <title>Slideshow using DomainUpDown and TransitionContentControl</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,8a472c80-1a8c-4d23-8b3e-c1cadbd4929c.aspx</guid>
      <link>http://www.sitechno.com/Blog/SlideshowUsingDomainUpDownAndTransitionContentControl.aspx</link>
      <pubDate>Mon, 27 Apr 2009 16:28:32 GMT</pubDate>
      <description>&lt;p&gt;
I’ve seen quite a few slideshow controls for Silverlight. Mostly they are either retemplated
listboxes (buying an easy transition effect for free) or custom controls. I’d like
to see how the DomainUpDown control can be used to do a slide show. This post also
takes a more indepth look at TransitioningContentControl and along the way shows how
to retemplate and inherit/extend other controls.
&lt;/p&gt;
&lt;p&gt;
The &lt;a href="http://www.sitechno.com/Blog/DomainUpDown.aspx"&gt;DomainUpDown&lt;/a&gt; control
allows you to visualize a ‘domain’, which can be anything. In our case, our domain
will consist of UIElements. The &lt;a href="http://www.sitechno.com/Blog/ct.ashx?id=d1845361-f351-478a-8724-c5b5fffb8d06&amp;amp;url=http%3a%2f%2fsilverlight.codeplex.com%2fWiki%2fView.aspx%3ftitle%3dSilverlight%2520Toolkit%2520Overview%2520Part%25201%26ANCHOR%23TransitioningContentControl"&gt;TransitionContentControl&lt;/a&gt; is
an experimental control that I haven’t featured on this blog yet. It is a ‘convenience’
control, with which I mean to say that the control just takes care of a very common
goal in Silverlight development. In this case, it will react to changes in Content
by transitioning old content out and transitioning new content in. I’ve talked briefly
about the control &lt;a href="http://www.sitechno.com/Blog/SilverlightToolkitMarch2009Released.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
By using DomainUpDown (henceforth: DUD), we will get a nice navigation system for
free (up/down arrows) and the option to show our domain in a cyclic way (in other
words, after you reach the end, it will jump to the first item again). Also, we have
the option to allow shortcuts into the domain, by having the user type in the control.
We will disable that though. 
&lt;/p&gt;
&lt;p&gt;
I certainly do not like the default look of the control though, with its big up/down
buttons. So, we have some work ahead of us.
&lt;/p&gt;
&lt;p&gt;
I’ve started out with a new SL2 application, adding references to:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
System.Windows.Controls.Toolkit 
&lt;/li&gt;
&lt;li&gt;
System.Windows.Controls.Toolkit.Input 
&lt;/li&gt;
&lt;li&gt;
System.Windows.Controls.Toolkit.Layout 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
These are part of the &lt;a href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I’ve also added a folder called Images and put some images in there. Just making it
easy on myself, I’ve hardcoded those images into the Items collection of my DUD. I
do not want users to be able to type in the DUD, so I set ‘IsEditable’ to false. I
know the images are 300*400, so I even hardcoded the width/height of the control.
I end up with this Xaml:
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;UserControl
  x:Class=&amp;quot;BlogImageSlideshow.Page&amp;quot;
  xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;
  xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;
  xmlns:inputToolkit=&amp;quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit&amp;quot;&amp;gt;
  &amp;lt;Grid
    x:Name=&amp;quot;LayoutRoot&amp;quot;
    Background=&amp;quot;White&amp;quot;&amp;gt;
    &amp;lt;inputToolkit:DomainUpDown
      Height=&amp;quot;300&amp;quot;
      Width=&amp;quot;400&amp;quot;
      IsEditable=&amp;quot;False&amp;quot;&amp;gt;
      &amp;lt;Image
        Source=&amp;quot;Images/3410783929_051d93bc86.jpg&amp;quot; /&amp;gt;
      &amp;lt;Image
        Source=&amp;quot;Images/3412190495_4099006101.jpg&amp;quot; /&amp;gt;
      &amp;lt;Image
        Source=&amp;quot;Images/3413898641_f975065242.jpg&amp;quot; /&amp;gt;
      &amp;lt;Image
        Source=&amp;quot;Images/3414953148_cec704b7b8.jpg&amp;quot; /&amp;gt;
      &amp;lt;Image
        Source=&amp;quot;Images/3415344995_730b5cc814.jpg&amp;quot; /&amp;gt;
    &amp;lt;/inputToolkit:DomainUpDown&amp;gt;
  &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;&lt;/pre&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
When we view the control though, we are in for a surprise:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb.png" width="390" height="304" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The buttons are way to big, and our image is way too small. This is caused by the
way those buttons are created (with paths, set to scale uniformly). In most situations
that will be exactly what you would like, however, in our case it most definitely
is not. We’ll want to retemplate our control and are going to do that the ‘easy’ way:
through Blend.
&lt;/p&gt;
&lt;p&gt;
Once in Blend, I choose to edit the template of the DUD, which creates a style for
me. The Object tab reveals the following parts of DUD:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_1.png" width="295" height="373" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
To fix the ugly buttons, let’s repeat the process and retemplate the Spinner (which
is a ButtonSpinner). That ButtonSpinner is responsible for hosting our content (in
the image that is a Grid with two children: ‘Visualization’ and ‘Text’. It is also
responsible for displaying the two buttons. 
&lt;/p&gt;
&lt;p&gt;
Editing the Spinner reveals these objects:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_2.png" width="301" height="347" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The unnamed [Button] is used to ‘catch’ the mouseclicks that are done on a disabled
button. We don’t need it, so I’ll remove it. Also, I don’t want the buttons on the
right side, but I want the previous button on the left and the next button on the
right. I actually have a great idea: I’ll overlay the buttons and make them transparent.
That way, pressing on the right side of the image will move the slideshow forwards
and pressing on the left side will make it go backwards.
&lt;/p&gt;
&lt;p&gt;
I also retemplated the buttons: removing the usual gradient, but having some overlay
on ‘mouseOver’ to indicate that we can press. Since I’m no designer, I just used a
one white rectangle with an opacity of 0 and a linear gradient opacitymask. On MouseOver,
I will animate the opacity to 30%. The effect is a gradual whitening at the border
of the image.
&lt;/p&gt;
&lt;p&gt;
This is the style for one of the buttons:
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;Style x:Key=&amp;quot;RepeatButtonStyle1&amp;quot; TargetType=&amp;quot;RepeatButton&amp;quot;&amp;gt;
    &amp;lt;Setter Property=&amp;quot;Background&amp;quot; Value=&amp;quot;#FF1F3B53&amp;quot;/&amp;gt;
    &amp;lt;Setter Property=&amp;quot;Foreground&amp;quot; Value=&amp;quot;#FF000000&amp;quot;/&amp;gt;
    &amp;lt;Setter Property=&amp;quot;Padding&amp;quot; Value=&amp;quot;3&amp;quot;/&amp;gt;
    &amp;lt;Setter Property=&amp;quot;BorderThickness&amp;quot; Value=&amp;quot;1&amp;quot;/&amp;gt;
    &amp;lt;Setter Property=&amp;quot;BorderBrush&amp;quot;&amp;gt;
        &amp;lt;Setter.Value&amp;gt;
            &amp;lt;LinearGradientBrush EndPoint=&amp;quot;0.5,1&amp;quot; StartPoint=&amp;quot;0.5,0&amp;quot;&amp;gt;
                &amp;lt;GradientStop Color=&amp;quot;#FFA3AEB9&amp;quot; Offset=&amp;quot;0&amp;quot;/&amp;gt;
                &amp;lt;GradientStop Color=&amp;quot;#FF8399A9&amp;quot; Offset=&amp;quot;0.375&amp;quot;/&amp;gt;
                &amp;lt;GradientStop Color=&amp;quot;#FF718597&amp;quot; Offset=&amp;quot;0.375&amp;quot;/&amp;gt;
                &amp;lt;GradientStop Color=&amp;quot;#FF617584&amp;quot; Offset=&amp;quot;1&amp;quot;/&amp;gt;
            &amp;lt;/LinearGradientBrush&amp;gt;
        &amp;lt;/Setter.Value&amp;gt;
    &amp;lt;/Setter&amp;gt;
    &amp;lt;Setter Property=&amp;quot;Template&amp;quot;&amp;gt;
        &amp;lt;Setter.Value&amp;gt;
            &amp;lt;ControlTemplate TargetType=&amp;quot;RepeatButton&amp;quot;&amp;gt;
                &amp;lt;Grid x:Name=&amp;quot;Root&amp;quot;&amp;gt;
                    &amp;lt;vsm:VisualStateManager.VisualStateGroups&amp;gt;
                        &amp;lt;vsm:VisualStateGroup x:Name=&amp;quot;CommonStates&amp;quot;&amp;gt;
                            &amp;lt;vsm:VisualState x:Name=&amp;quot;Normal&amp;quot;/&amp;gt;
                            &amp;lt;vsm:VisualState x:Name=&amp;quot;MouseOver&amp;quot;&amp;gt;
                                &amp;lt;Storyboard&amp;gt;
                                    &amp;lt;DoubleAnimationUsingKeyFrames BeginTime=&amp;quot;00:00:00&amp;quot; Storyboard.TargetName=&amp;quot;rectangle&amp;quot; Storyboard.TargetProperty=&amp;quot;(UIElement.Opacity)&amp;quot;&amp;gt;
                                        &amp;lt;SplineDoubleKeyFrame KeyTime=&amp;quot;00:00:00.5000000&amp;quot; Value=&amp;quot;0.3&amp;quot;/&amp;gt;
                                    &amp;lt;/DoubleAnimationUsingKeyFrames&amp;gt;
                                &amp;lt;/Storyboard&amp;gt;
                            &amp;lt;/vsm:VisualState&amp;gt;
                            &amp;lt;vsm:VisualState x:Name=&amp;quot;Pressed&amp;quot;&amp;gt;
                                &amp;lt;Storyboard/&amp;gt;
                            &amp;lt;/vsm:VisualState&amp;gt;
                            &amp;lt;vsm:VisualState x:Name=&amp;quot;Disabled&amp;quot;&amp;gt;
                                &amp;lt;Storyboard/&amp;gt;
                            &amp;lt;/vsm:VisualState&amp;gt;
                        &amp;lt;/vsm:VisualStateGroup&amp;gt;
                        &amp;lt;vsm:VisualStateGroup x:Name=&amp;quot;FocusStates&amp;quot;&amp;gt;
                            &amp;lt;vsm:VisualState x:Name=&amp;quot;Focused&amp;quot;&amp;gt;
                                &amp;lt;Storyboard/&amp;gt;
                            &amp;lt;/vsm:VisualState&amp;gt;
                            &amp;lt;vsm:VisualState x:Name=&amp;quot;Unfocused&amp;quot;/&amp;gt;
                        &amp;lt;/vsm:VisualStateGroup&amp;gt;
                    &amp;lt;/vsm:VisualStateManager.VisualStateGroups&amp;gt;
                    &amp;lt;Rectangle Height=&amp;quot;Auto&amp;quot; Margin=&amp;quot;0,0,0,0&amp;quot; VerticalAlignment=&amp;quot;Stretch&amp;quot; Stroke=&amp;quot;#FF000000&amp;quot; Opacity=&amp;quot;0&amp;quot; x:Name=&amp;quot;rectangle&amp;quot; Fill=&amp;quot;#FFFFFFFF&amp;quot;&amp;gt;
                        &amp;lt;Rectangle.OpacityMask&amp;gt;
                            &amp;lt;LinearGradientBrush EndPoint=&amp;quot;-0.015,0.493&amp;quot; StartPoint=&amp;quot;0.99,0.497&amp;quot;&amp;gt;
                                &amp;lt;GradientStop Color=&amp;quot;#00000000&amp;quot;/&amp;gt;
                                &amp;lt;GradientStop Color=&amp;quot;#FFFFFFFF&amp;quot; Offset=&amp;quot;1&amp;quot;/&amp;gt;
                            &amp;lt;/LinearGradientBrush&amp;gt;
                        &amp;lt;/Rectangle.OpacityMask&amp;gt;
                    &amp;lt;/Rectangle&amp;gt;
                &amp;lt;/Grid&amp;gt;
            &amp;lt;/ControlTemplate&amp;gt;
        &amp;lt;/Setter.Value&amp;gt;
    &amp;lt;/Setter&amp;gt;
&amp;lt;/Style&amp;gt;&lt;/pre&gt;
&lt;h5&gt;And now for the fun stuff: Animating it!
&lt;/h5&gt;
&lt;p&gt;
Currently the status of the project is that I am able to quickly show a bunch of images
and I can mouse over the image and click to show the next/previous image. We’re now
going to dive into the TransitioningContentControl and use it to create a nice sliding
effect.
&lt;/p&gt;
&lt;p&gt;
First some background: in Silverlight and in WPF, you use a ContentControl to visualize
any type of content you might have. When setting a new content, the ContentControl
will just replace the current visual with a new visual (representing your new content).
It uses a ContentTemplate to determine how to visualize your content. 
&lt;br /&gt;
The only feature that TransitioningContentControl adds to this game is an easy way
to start an animation to visualize the actual replacing of content. Although there
are some technical difficulties (more on that later), it is meant as a drop-in replacement
for ContentControl.
&lt;/p&gt;
&lt;p&gt;
The DomainUpDown also uses a ContentControl to show your content. The templatepart
is called ‘Visualization’ and we are going to replace that with a TransitioningContentControl.
All I did was replace the ContentControl tag with TransitioningContentControl in the
template for DomainUpDown. 
&lt;/p&gt;
&lt;p&gt;
Now, here comes the catch: because an element can’t be in the visual tree twice (at
the same time) in SL2 this creates a bit of a problem when using the TCC (TransitioningContentControl)
with FrameworkElements. In SL3 I will solve this quite easily by creating an image
out of the content and using that to ‘transition out’ but in SL2 the only easy work-around
is to not use elements with this control. That is actually quite easy, because we
can use the ContentTemplate to create our elements on the fly. I’ve changed the way
I use DUD as follow:
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;inputToolkit:DomainUpDown
    Height=&amp;quot;300&amp;quot; Width=&amp;quot;400&amp;quot;
    IsEditable=&amp;quot;False&amp;quot; Style=&amp;quot;{StaticResource SlideShowStyle}&amp;quot;&amp;gt;
&amp;lt;inputToolkit:DomainUpDown.ItemTemplate&amp;gt;
  &amp;lt;DataTemplate&amp;gt;
    &amp;lt;Image Source=&amp;quot;{Binding}&amp;quot; /&amp;gt;
  &amp;lt;/DataTemplate&amp;gt;
&amp;lt;/inputToolkit:DomainUpDown.ItemTemplate&amp;gt;
&amp;lt;System:String&amp;gt;Images/3410783929_051d93bc86.jpg&amp;lt;/System:String&amp;gt;
&amp;lt;System:String&amp;gt;Images/3412190495_4099006101.jpg&amp;lt;/System:String&amp;gt;
&amp;lt;System:String&amp;gt;Images/3413898641_f975065242.jpg&amp;lt;/System:String&amp;gt;
&amp;lt;System:String&amp;gt;Images/3414953148_cec704b7b8.jpg&amp;lt;/System:String&amp;gt;
&amp;lt;System:String&amp;gt;Images/3415344995_730b5cc814.jpg&amp;lt;/System:String&amp;gt;
&amp;lt;/inputToolkit:DomainUpDown&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Because the TCC actually has a nice default transition, we could call it a day: there
is a nice fade-in/fade-out animation going on. I like it! 
&lt;br /&gt;
However, let’s see if we can actually create a slideshow.
&lt;/p&gt;
&lt;p&gt;
To start off, I went ahead and edited the template for TransitioningContentControl.
In Blend3 there seems to be a bug that not the complete template is copied (making
it rather useless). Blend2 works fine though. 
&lt;br /&gt;
The inevitable object screenshot shows 
&lt;br /&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_3.png" width="308" height="227" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
two ‘presentationSites’. Which enables you to see through my trickery: the only thing
I do when content is being set, is copy the content inside ‘CurrentContentPresentation’
to ‘PreviousContentPresentation’ and start a storyboard. These are the storyboards
that come out of the box:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_4.png" width="312" height="270" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Now, I fully expect you to create / add your own transitions here. To do that, you
would go into xaml and add an empty storyboard. At that point you can use the designer
again to style it. However, we’ll be fine by restyling the UpTransition and DownTransition. 
&lt;/p&gt;
&lt;p&gt;
Currently they do a nice fade and rendertransform. That doesn’t work for me though,
so let’s start with the UpTransition, I’d like to have the PreviousContentPresentationSite
move to the left and have the Current come in from the right. 
&lt;br /&gt;
That’s pretty easy, I just animated two rendertransforms to do that, not forgetting
to set a nice keyspline for the smooth effect.
&lt;/p&gt;
&lt;p&gt;
Next assignment: we’ll need to let TCC know which transition to use. It has no knowledge
of the concept of up or down or whatever transitions you came up with. 
&lt;br /&gt;
To be able to tell TCC which transition to play, I expose a DependencyProperty of
type string. That indicates the exact name of the transition that should be used the
next time the content is changed. 
&lt;/p&gt;
&lt;p&gt;
There are many ways to do this. You could hook into the buttons and set the Transition
manually. I believe the easiest way though, is to inherit from DomainUpDown and add
the functionality yourself:
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public class SlidingDomainUpDown : DomainUpDown
{
    private TransitioningContentControl _visualizer;

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();

        _visualizer = GetTemplateChild(&amp;quot;Visualization&amp;quot;) as TransitioningContentControl;
    }

    protected override void OnDecrement()
    {
        if (_visualizer != null)
        {
            _visualizer.Transition = &amp;quot;DownTransition&amp;quot;;
        }
        base.OnDecrement();
    }

    protected override void OnIncrement()
    {

        if (_visualizer != null)
        {
            _visualizer.Transition = &amp;quot;UpTransition&amp;quot;;
        }

        base.OnIncrement();
    }
}&lt;/pre&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Interestingly enough, I get asked how to get to templateparts all the time, on the
silverlight.net forums. Well, here you go: the simplest possible example there is.
I hope this is clear!
&lt;/p&gt;
&lt;p&gt;
At this point, everything works fine for me. Except that the effect is horrible! You
see the complete image moving, but you would expect to only see it inside of the frame.
What we need is some clipping. 
&lt;br /&gt;
I’m no Blend hero, but I pulled it off by creating a rectangle and right-clicking,
choosing Path/make clipping path. Then I chose the TCC element, called ‘Visualization’
to be the clipping target. It ended up creating this xaml: 
&lt;/p&gt;
&lt;p&gt;
Clip=&amp;quot;M0.5,0.5 L395.5,0.5 L395.5,295.5 L0.5,295.5 z&amp;quot;
&lt;/p&gt;
&lt;p&gt;
We’re now at a point that I’m really happy about! The user has some feedback when
he mouses over the image and the effect is quite nice. The user can click too fast
though (while the transition is in motion) and I’d like to disable that:
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;protected override void OnValueChanging(RoutedPropertyChangingEventArgs&amp;lt;object&amp;gt; e)
{
    base.OnValueChanging(e);

    if (_visualizer != null &amp;amp;&amp;amp; _visualizer.IsTransitioning)
    {
        e.Cancel = true;
    }
}&lt;/pre&gt;
&lt;p&gt;
It would have been nicer to disable the buttons, but this will do for now.
&lt;/p&gt;
&lt;h5&gt;Taking the extra step: adding direct shortcuts
&lt;/h5&gt;
&lt;p&gt;
This is becoming a huge post, but I’m having too much fun. 
&lt;br /&gt;
You have seen slideshows that have little indicators on the buttom that allow you
to directly navigate to an image. I’m thinking of the Hulu.com example:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_5.png" width="385" height="168" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Let’s create those!
&lt;/p&gt;
&lt;p&gt;
I started by adding a ListBox to the template of our SlidingDomainUpDown control.
I cheated a bit and hardlinked the Items collection to the ItemsSource collection
of that ListBox. 
&lt;br /&gt;
Then I went on to restyle the ListBoxItems to show a small preview of our item. Then
I hooked up the ListBox.SelectionChanged event. When the selecteditem changes, I just
set the Value of the DomainUpDown. Obviously, this could have been more elegantly
done by creating a binding between the Value property and the SelectedItem property
of the ListBox.&amp;#160; (oh well, it’s my blog! :) ) 
&lt;br /&gt;
I also cheated because I did not spend the time looking at the key handling. The listbox
actually takes care of some of the keyhandling, and I don’t like it. 
&lt;/p&gt;
&lt;p&gt;
I end up with this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/SlideshowusingDomainUpDownandTransitionC_C247/image_thumb_6.png" width="355" height="351" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I set up the transition to be the DefaultTransition (which is a nice fade in/fade
out). So, now the user can slide or go directly to an image. Loving it!
&lt;/p&gt;
&lt;p&gt;
Try it out &lt;a href="http://www.sitechno.com/Silverlight/DUD_TCC/BlogImageSlideshowSource.zip"&gt;here&lt;/a&gt; and
grab the solution &lt;a href="http://www.sitechno.com/Silverlight/DUD_TCC/TestPage.html"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=8a472c80-1a8c-4d23-8b3e-c1cadbd4929c" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,8a472c80-1a8c-4d23-8b3e-c1cadbd4929c.aspx</comments>
      <category>Silverlight;Silverlight Toolkit</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=5fb8ee52-a629-406c-acdf-6a0841ea2f13</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,5fb8ee52-a629-406c-acdf-6a0841ea2f13.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,5fb8ee52-a629-406c-acdf-6a0841ea2f13.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=5fb8ee52-a629-406c-acdf-6a0841ea2f13</wfw:commentRss>
      <slash:comments>33</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://themechanicalbride.blogspot.com/2009/04/f-solution-to-eric-lippert-challenge.html" target="_blank">Jafar
Husain</a> told me that he was working on a challenge by <a href="http://blogs.msdn.com/ericlippert/archive/2009/04/15/comma-quibbling.aspx" target="_blank">Eric
Lippert</a>. <a href="http://blogs.msdn.com/delay/" target="_blank">David Anson</a> followed
and they posted solutions to the challenge on their blog. I thought it was quite a
bit of fun so I quickly wrote something up that I like. 
</p>
        <p>
I will copy the problem from Erics website. It challenges you to transform a sequence
of strings into a nicely delimited form.
</p>
        <p>
(1) If the sequence is empty then the resulting string is "{}". 
<br />
(2) If the sequence is a single item "ABC" then the resulting string is
"{ABC}". 
<br />
(3) If the sequence is the two item sequence "ABC", "DEF" then
the resulting string is "{ABC and DEF}". 
<br />
(4) If the sequence has more than two items, say, "ABC", "DEF",
"G", "H" then the resulting string is "{ABC, DEF, G and H}".
(Note: no Oxford comma!)
</p>
        <p>
He noted he was mostly interested in readable code, so I came up with a nice Linq
solution. However, Jafar was unimpressed and noted that performance was still important.
I was traversing the sequence too often for his taste. Back to the drawing board and
coming up with a less readable, but pretty quick implementation:
</p>
        <pre class="brush: csharp; gutter: false;">string lastWord = String.Empty;

StringBuilder sb = new StringBuilder();
foreach(string s in input)
{
    sb.Append(s);
    sb.Append(", ");
    lastWord = s;
}

int lastWordIndex = (sb.Length -1) - lastWord.Length - 3;

if (lastWordIndex &gt; 0)
{
    Console.WriteLine("{" + sb.ToString(0, lastWordIndex) + " and " + lastWord + "}");
}
else if (sb.Length == 0)
{
    Console.WriteLine("{}");
}
else
{
    Console.WriteLine("{" + sb.ToString(0, sb.Length -2) + "}");
}</pre>
        <p>
 
</p>
        <p>
I like this solution quite a bit. Obviously not optimized the return statements, and
the readability is quite a bit worse than my first attempt. But it’s short, only goes
over the sequence once and should perform well. 
</p>
        <p>
          <strong>edit:</strong> The linq version:
</p>
        <pre class="brush: csharp; gutter: false;">StringBuilder t = new StringBuilder();

            int count = input.Count();

            var middleStrings = input.Where((s, i) =&gt; i &gt; 0 &amp;&amp; i &lt; count - 1);

            t.Append("{");

            t.Append(input.FirstOrDefault());

            // linq reads better than foreach.
            middleStrings.ToList().ForEach(s =&gt;
                                              {
                                                 t.Append(", ");
                                                 t.Append(s);
                                              });

            if (count &gt; 1)
            {
                t.Append(" and ");
                t.Append(input.LastOrDefault());
            }

            t.Append("}");

            return t.ToString();</pre>
        <p>
Oh well. 
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=5fb8ee52-a629-406c-acdf-6a0841ea2f13" />
      </body>
      <title>Comma quibbling</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,5fb8ee52-a629-406c-acdf-6a0841ea2f13.aspx</guid>
      <link>http://www.sitechno.com/Blog/CommaQuibbling.aspx</link>
      <pubDate>Fri, 17 Apr 2009 04:15:54 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://themechanicalbride.blogspot.com/2009/04/f-solution-to-eric-lippert-challenge.html" target="_blank"&gt;Jafar
Husain&lt;/a&gt; told me that he was working on a challenge by &lt;a href="http://blogs.msdn.com/ericlippert/archive/2009/04/15/comma-quibbling.aspx" target="_blank"&gt;Eric
Lippert&lt;/a&gt;. &lt;a href="http://blogs.msdn.com/delay/" target="_blank"&gt;David Anson&lt;/a&gt; followed
and they posted solutions to the challenge on their blog. I thought it was quite a
bit of fun so I quickly wrote something up that I like. 
&lt;/p&gt;
&lt;p&gt;
I will copy the problem from Erics website. It challenges you to transform a sequence
of strings into a nicely delimited form.
&lt;/p&gt;
&lt;p&gt;
(1) If the sequence is empty then the resulting string is &amp;quot;{}&amp;quot;. 
&lt;br /&gt;
(2) If the sequence is a single item &amp;quot;ABC&amp;quot; then the resulting string is
&amp;quot;{ABC}&amp;quot;. 
&lt;br /&gt;
(3) If the sequence is the two item sequence &amp;quot;ABC&amp;quot;, &amp;quot;DEF&amp;quot; then
the resulting string is &amp;quot;{ABC and DEF}&amp;quot;. 
&lt;br /&gt;
(4) If the sequence has more than two items, say, &amp;quot;ABC&amp;quot;, &amp;quot;DEF&amp;quot;,
&amp;quot;G&amp;quot;, &amp;quot;H&amp;quot; then the resulting string is &amp;quot;{ABC, DEF, G and H}&amp;quot;.
(Note: no Oxford comma!)
&lt;/p&gt;
&lt;p&gt;
He noted he was mostly interested in readable code, so I came up with a nice Linq
solution. However, Jafar was unimpressed and noted that performance was still important.
I was traversing the sequence too often for his taste. Back to the drawing board and
coming up with a less readable, but pretty quick implementation:
&lt;/p&gt;
&lt;pre class="brush: csharp; gutter: false;"&gt;string lastWord = String.Empty;

StringBuilder sb = new StringBuilder();
foreach(string s in input)
{
    sb.Append(s);
    sb.Append(&amp;quot;, &amp;quot;);
    lastWord = s;
}

int lastWordIndex = (sb.Length -1) - lastWord.Length - 3;

if (lastWordIndex &amp;gt; 0)
{
    Console.WriteLine(&amp;quot;{&amp;quot; + sb.ToString(0, lastWordIndex) + &amp;quot; and &amp;quot; + lastWord + &amp;quot;}&amp;quot;);
}
else if (sb.Length == 0)
{
    Console.WriteLine(&amp;quot;{}&amp;quot;);
}
else
{
    Console.WriteLine(&amp;quot;{&amp;quot; + sb.ToString(0, sb.Length -2) + &amp;quot;}&amp;quot;);
}&lt;/pre&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
I like this solution quite a bit. Obviously not optimized the return statements, and
the readability is quite a bit worse than my first attempt. But it’s short, only goes
over the sequence once and should perform well. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;edit:&lt;/strong&gt; The linq version:
&lt;/p&gt;
&lt;pre class="brush: csharp; gutter: false;"&gt;StringBuilder t = new StringBuilder();

            int count = input.Count();

            var middleStrings = input.Where((s, i) =&amp;gt; i &amp;gt; 0 &amp;amp;&amp;amp; i &amp;lt; count - 1);

            t.Append(&amp;quot;{&amp;quot;);

            t.Append(input.FirstOrDefault());

            // linq reads better than foreach.
            middleStrings.ToList().ForEach(s =&amp;gt;
                                              {
                                                 t.Append(&amp;quot;, &amp;quot;);
                                                 t.Append(s);
                                              });

            if (count &amp;gt; 1)
            {
                t.Append(&amp;quot; and &amp;quot;);
                t.Append(input.LastOrDefault());
            }

            t.Append(&amp;quot;}&amp;quot;);

            return t.ToString();&lt;/pre&gt;
&lt;p&gt;
Oh well. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=5fb8ee52-a629-406c-acdf-6a0841ea2f13" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,5fb8ee52-a629-406c-acdf-6a0841ea2f13.aspx</comments>
      <category>Code</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=17d1cf77-0b08-40bc-86eb-81c42a8b2e6f</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,17d1cf77-0b08-40bc-86eb-81c42a8b2e6f.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,17d1cf77-0b08-40bc-86eb-81c42a8b2e6f.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=17d1cf77-0b08-40bc-86eb-81c42a8b2e6f</wfw:commentRss>
      <slash:comments>26</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In a <a href="http://www.sitechno.com/Blog/SpeedUpIE8Tips.aspx" target="_blank">previous
post</a> I mentioned ways to speed up IE8. For me, having used Spybot a long time
ago proved to be the culprit: it had added a slew of sites (hundreds) to the blocked
sites zone. I removed it and all was well..
</p>
        <p>
Or was it?
</p>
        <p>
I noticed that IE8 still did not come up as quick as it did on my other computers.
Opening a tab was fast, but opening another tab proved to be slow. Actually, I found
that the first tab I opened was fast, the next one was slow, the following was fast
again. Possibly some pre-creation of processes going on?
</p>
        <p>
Today I finally did the smart thing and hooked up filemon to see what was actually
going on. It turns out that there were still hundreds of domains somewhere hidden
in my registry. They no longer showed up in any dialog box concerning security, but
they were there! I removed the key and now IE8 is <strong>really</strong> fast. As
in, faster than Chrome or Firefox, when opening new tabs. Incredible!
</p>
        <p>
So, if you feel that IE8 is still a bit sluggish for you, go and see what the following
registry key contains:
</p>
        <p>
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Internet
Settings\ZoneMap\Domains
</p>
        <p>
(Note that I’m on a x64 machine, hence the WOW64 node).
</p>
        <p>
My solution is to delete the Domains key.
</p>
        <p>
          <font size="1">(I can’t even convey how happy I am with this simple find. We all spend
a lot of our time inside our browser and I like IE8 better than other browsers. It
is just a very capable and well-thought-out user experience. But if something is slow,
it kills the experience!)</font>
        </p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=17d1cf77-0b08-40bc-86eb-81c42a8b2e6f" />
      </body>
      <title>Internet explorer 8 speed, update</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,17d1cf77-0b08-40bc-86eb-81c42a8b2e6f.aspx</guid>
      <link>http://www.sitechno.com/Blog/InternetExplorer8SpeedUpdate.aspx</link>
      <pubDate>Sun, 12 Apr 2009 00:29:47 GMT</pubDate>
      <description>&lt;p&gt;
In a &lt;a href="http://www.sitechno.com/Blog/SpeedUpIE8Tips.aspx" target="_blank"&gt;previous
post&lt;/a&gt; I mentioned ways to speed up IE8. For me, having used Spybot a long time
ago proved to be the culprit: it had added a slew of sites (hundreds) to the blocked
sites zone. I removed it and all was well..
&lt;/p&gt;
&lt;p&gt;
Or was it?
&lt;/p&gt;
&lt;p&gt;
I noticed that IE8 still did not come up as quick as it did on my other computers.
Opening a tab was fast, but opening another tab proved to be slow. Actually, I found
that the first tab I opened was fast, the next one was slow, the following was fast
again. Possibly some pre-creation of processes going on?
&lt;/p&gt;
&lt;p&gt;
Today I finally did the smart thing and hooked up filemon to see what was actually
going on. It turns out that there were still hundreds of domains somewhere hidden
in my registry. They no longer showed up in any dialog box concerning security, but
they were there! I removed the key and now IE8 is &lt;strong&gt;really&lt;/strong&gt; fast. As
in, faster than Chrome or Firefox, when opening new tabs. Incredible!
&lt;/p&gt;
&lt;p&gt;
So, if you feel that IE8 is still a bit sluggish for you, go and see what the following
registry key contains:
&lt;/p&gt;
&lt;p&gt;
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Internet
Settings\ZoneMap\Domains
&lt;/p&gt;
&lt;p&gt;
(Note that I’m on a x64 machine, hence the WOW64 node).
&lt;/p&gt;
&lt;p&gt;
My solution is to delete the Domains key.
&lt;/p&gt;
&lt;p&gt;
&lt;font size="1"&gt;(I can’t even convey how happy I am with this simple find. We all spend
a lot of our time inside our browser and I like IE8 better than other browsers. It
is just a very capable and well-thought-out user experience. But if something is slow,
it kills the experience!)&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=17d1cf77-0b08-40bc-86eb-81c42a8b2e6f" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,17d1cf77-0b08-40bc-86eb-81c42a8b2e6f.aspx</comments>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=1b37749a-295b-4696-96af-b9d8de1c7fb2</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,1b37749a-295b-4696-96af-b9d8de1c7fb2.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,1b37749a-295b-4696-96af-b9d8de1c7fb2.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=1b37749a-295b-4696-96af-b9d8de1c7fb2</wfw:commentRss>
      <slash:comments>155</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I believe this is going to be the last post in this series, although I bet I will
have some loose Accordion posts coming up. This part is going to focus on AccordionButton,
and show you how to retemplate it. 
</p>
        <p>
Previous posts: 
<br /><a href="http://www.sitechno.com/Blog/AccordionPart1.aspx" target="_blank">Part 1</a> –
accordion 
<br /><a href="http://www.sitechno.com/Blog/AccordionPart2.aspx" target="_blank">Part 2</a> –
accordion item 
<br /><a href="http://www.sitechno.com/Blog/AccordionPart3.aspx" target="_blank">Part 3</a> –
expandable content control 
<br /><a href="http://www.sitechno.com/Blog/AccordionPart4TemplatingExample.aspx" target="_blank">Part
4</a> – retemplating, real world example
</p>
        <p>
We’ve already hit on a lot of the internals of AccordionItem. Expandable content control
was used to easily animate the size of the content. When looking at the header though,
it gets complicated all over again.
</p>
        <p>
This is the important part of AccordionItem, defining both a place for the content
and a place for the header:
</p>
        <pre class="brush: xml; gutter: false;">&lt;Border x:Name="Background" 
        Padding="{TemplateBinding Padding}" 
        BorderBrush="{TemplateBinding BorderBrush}" 
        BorderThickness="{TemplateBinding BorderThickness}" 
        CornerRadius="1,1,1,1"&gt;
    &lt;Grid&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition Height="Auto" x:Name="rd0"/&gt;
            &lt;RowDefinition Height="Auto" x:Name="rd1"/&gt;
        &lt;/Grid.RowDefinitions&gt;
        &lt;Grid.ColumnDefinitions&gt;
            &lt;ColumnDefinition Width="Auto" x:Name="cd0"/&gt;
            &lt;ColumnDefinition Width="Auto" x:Name="cd1"/&gt;
        &lt;/Grid.ColumnDefinitions&gt;

        &lt;layoutPrimitivesToolkit:AccordionButton
                    x:Name="ExpanderButton"
          Style="{TemplateBinding AccordionButtonStyle}"
                    Content="{TemplateBinding Header}"
                    ContentTemplate="{TemplateBinding HeaderTemplate}"
                    IsChecked="{TemplateBinding IsSelected}"
                    IsTabStop="True"
                    Grid.Row="0"
                    Padding="0,0,0,0"
                    Margin="0,0,0,0"
                    FontFamily="{TemplateBinding FontFamily}"
                    FontSize="{TemplateBinding FontSize}"
                    FontStretch="{TemplateBinding FontStretch}"
                    FontStyle="{TemplateBinding FontStyle}"
                    FontWeight="{TemplateBinding FontWeight}"
                    Foreground="{TemplateBinding Foreground}"
                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" 
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch" 
          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
          Background="{TemplateBinding Background}" /&gt;

        &lt;layoutPrimitivesToolkit:ExpandableContentControl
                    x:Name="ExpandSite"
                    Grid.Row="1"
                    IsTabStop="False"
                    Percentage="0"
                    RevealMode="{TemplateBinding ExpandDirection}"
                    Content="{TemplateBinding Content}"
                    ContentTemplate="{TemplateBinding ContentTemplate}"
                    Margin="0,0,0,0"
                    FontFamily="{TemplateBinding FontFamily}"
                    FontSize="{TemplateBinding FontSize}"
                    FontStretch="{TemplateBinding FontStretch}"
                    FontStyle="{TemplateBinding FontStyle}"
                    FontWeight="{TemplateBinding FontWeight}"
                    Foreground="{TemplateBinding Foreground}"
                    HorizontalContentAlignment="Left"
                    VerticalContentAlignment="Top" 
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"/&gt;
    &lt;/Grid&gt;
&lt;/Border&gt;</pre>
        <p>
          <br />
        </p>
        <p>
As you can see, both ExpandableContentControl and AccordionButton are placed in the
primitives namespace. More importantly, they are placed in a grid. As I’ve shown in
previous posts, that is how we react to the ExpandDirection setting on accordion (so
placing the content in the first column and the button in the second would correspond
to the ExpandDirection ‘right’). 
</p>
        <p>
AccordionButton is an extremely simple class. It inherits from ToggleButton, and its
whole purpose in life is to be able to react (once again) to different ExpandDirections.
So, if you were to open up the code of AccordionButton, you would see that all it
does is this:
</p>
        <pre class="brush: csharp; gutter: false;">switch (ParentAccordionItem.ExpandDirection)
{
    case ExpandDirection.Down:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandDown);
        break;

    case ExpandDirection.Up:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandUp);
        break;

    case ExpandDirection.Left:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandLeft);
        break;

    default:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandRight);
        break;
}</pre>
        <p>
Ofcourse, the template of AccordionButton is quite big. This is the reason I introduced
this class, just to simplify the template (considerably).
</p>
        <p>
It is time to look at the important part of AccordionButtons template:
</p>
        <pre class="brush: xml; gutter: false;">&lt;Border x:Name="background" Background="{TemplateBinding Background}" CornerRadius="1,1,1,1"&gt;
    &lt;Grid&gt;
        &lt;Border Height="Auto" Margin="0,0,0,0" x:Name="ExpandedBackground" VerticalAlignment="Stretch" Opacity="0" Background="#FFBADDE9" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1,1,1,1"/&gt;
        &lt;Border Height="Auto" Margin="0,0,0,0" x:Name="MouseOverBackground" VerticalAlignment="Stretch" Opacity="0" Background="#FFBDBDBD" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1,1,1,1"/&gt;
        &lt;Grid Background="Transparent"&gt;
            &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="Auto" x:Name="cd0"/&gt;
                &lt;ColumnDefinition Width="Auto" x:Name="cd1"/&gt;
            &lt;/Grid.ColumnDefinitions&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition Height="Auto" x:Name="rd0"/&gt;
                &lt;RowDefinition Height="Auto" x:Name="rd1"/&gt;
            &lt;/Grid.RowDefinitions&gt;
            &lt;Grid Height="19" HorizontalAlignment="Center" x:Name="icon" VerticalAlignment="Center" Width="19" RenderTransformOrigin="0.5,0.5" Grid.Column="0" Grid.Row="0"&gt;
                &lt;Grid.RenderTransform&gt;
                    &lt;TransformGroup&gt;
                        &lt;ScaleTransform/&gt;
                        &lt;SkewTransform/&gt;
                        &lt;RotateTransform Angle="-90"/&gt;
                        &lt;TranslateTransform/&gt;
                    &lt;/TransformGroup&gt;
                &lt;/Grid.RenderTransform&gt;
                &lt;Path 
                    Height="Auto" 
                    HorizontalAlignment="Center" 
                    Margin="0,0,0,0" x:Name="arrow" 
                    VerticalAlignment="Center" 
                    Width="Auto" 
                    RenderTransformOrigin="0.5,0.5" 
                    Stroke="#666" 
                    StrokeThickness="2" 
                    Data="M 1,1.5 L 4.5,5 L 8,1.5"&gt;
                    &lt;Path.RenderTransform&gt;
                        &lt;TransformGroup&gt;
                            &lt;ScaleTransform/&gt;
                            &lt;SkewTransform/&gt;
                            &lt;RotateTransform/&gt;
                            &lt;TranslateTransform/&gt;
                        &lt;/TransformGroup&gt;
                    &lt;/Path.RenderTransform&gt;
                &lt;/Path&gt;
            &lt;/Grid&gt;
            &lt;layoutToolkit:LayoutTransformer
                FontFamily="{TemplateBinding FontFamily}" 
                FontSize="{TemplateBinding FontSize}" 
                FontStretch="{TemplateBinding FontStretch}" 
                FontStyle="{TemplateBinding FontStyle}" 
                FontWeight="{TemplateBinding FontWeight}" 
                Foreground="{TemplateBinding Foreground}" 
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                Margin="6,6,6,0" 
                x:Name="header" 
                Grid.Column="0"
                Grid.Row="0" 
                Grid.RowSpan="1" 
                Content="{TemplateBinding Content}" 
                ContentTemplate="{TemplateBinding ContentTemplate}"/&gt;
        &lt;/Grid&gt;
    &lt;/Grid&gt;
&lt;/Border&gt;</pre>
        <p>
There are two parts here. We have a grid (named ’icon’) and a LayoutTransformer. Again,
we see the old trick of a grid with 2 columns and 2 rows: it is used to place the
icon relative to the header.
</p>
        <p>
Layouttransformer: it is a class that my teammate Delay has developed and was able
to ship with the toolkit. He has a whole host of blog posts about it, and his latest
may be of most interest to you: it shows how to animate the <a href="http://blogs.msdn.com/delay/archive/2009/04/10/a-bit-more-er-than-meets-the-eye-easily-animate-and-update-layouttransformer-with-animationmediator.aspx" target="_blank">layoutTransformer</a>. 
<br />
LayoutTransformer is a control that allows me to rotate the header and keeping the
layout engine happy. In other words, I rotate the header 90 degrees, and the width
and height of the header is correct. That would not be the case if I had used RenderTransform. 
<br />
I will not focus on this class any more, please checkout Delays posts on it!
</p>
        <p>
By now, you should have enough understanding of what is going on to be able to retemplate
AccordionButton:
</p>
        <ol>
          <li>
It holds both the Header and an icon</li>
          <li>
It reacts to expanddirection</li>
          <li>
It re-arranges the location of the button and header accordingly</li>
        </ol>
        <p>
Actually, it also rotates the icon. So when you are in ExpandDirection ‘right’, the
arrow in the button will still point towards the content, even though its location
is completely different from ExpandDirection ‘left’. 
</p>
        <h5>Templating the AccordionButton
</h5>
        <p>
We have hidden AccordionButton from the designer surface. We did that because we feel
that, as a primitive, there is no value in having AccordionButton clutter up the design
toolbox. However, in order to template it, it is easiest to use blend with only an
AccordionButton there.. So I used this Xaml in Blend:
</p>
        <pre class="brush: xml; gutter: false;">&lt;UserControl x:Class="AccordionBlogSamplesSL2.HorizontalImages"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit" 
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:System_Windows_Controls_Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit" 
    &gt;
  &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
      &lt;System_Windows_Controls_Primitives:AccordionButton /&gt;
  &lt;/Grid&gt;
&lt;/UserControl&gt;</pre>
        <p>
That gives me a nice design surface with an AccordionButton on it. When I attempt
to ‘Edit template’, Blend will create the style and shows the objects inside of AccordionButton:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb.png" width="251" height="315" />
          </a>
        </p>
        <p>
Not only that, it also shows me these states:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_1.png" width="281" height="632" />
          </a>
        </p>
        <p>
When pressing any of the ExpandDirectionStates, you will notice the icon being rotated
and moved to different gridcells. It is easiest to remain in the Base state to do
your work. 
</p>
        <p>
I’m not a terribly good designer (one would argue I am in fact, a terribly bad designer),
so I would even attempt to make this look good. I will just change the template slightly
so I have <em>something</em> to show you!
</p>
        <p>
The design surface looks like this:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_2.png" width="324" height="314" />
          </a>
        </p>
        <p>
I will change the path (called arrow) to this:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_12.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_5.png" width="217" height="214" />
          </a>
        </p>
        <p>
I’ve also changed the MouseOverBackground to something random and the expanded background. 
<br />
Quite a few people have asked me how to change those properties, well, here they are.
They are part of the AccordionButton template. 
<br /></p>
        <h5>Bringing it all together
</h5>
        <p>
AccordionItem luckily exposes an AccordionButtonStyle, so in order to restyle our
AccordionItems to accept this AccordionButtonStyle, we simply apply it.
</p>
        <pre class="brush: xml; gutter: false;">&lt;layoutToolkit:Accordion&gt;
    &lt;layoutToolkit:AccordionItem Content="AccordionItem" AccordionButtonStyle="{StaticResource AccordionButtonStyle1}"/&gt;
    &lt;layoutToolkit:AccordionItem Content="AccordionItem" AccordionButtonStyle="{StaticResource AccordionButtonStyle1}"/&gt;
&lt;/layoutToolkit:Accordion&gt;</pre>
        <p>
As I’ve been getting some questions on my blog about styles and templates, I will
also show you how to do this with an AccordionItemContainerStyle:
</p>
        <pre class="brush: xml; gutter: false;">&lt;layoutToolkit:Accordion&gt;
&lt;layoutToolkit:Accordion.ItemContainerStyle&gt;
    &lt;Style TargetType="layoutToolkit:AccordionItem"&gt;
     &lt;Setter Property="AccordionButtonStyle" Value="{StaticResource AccordionButtonStyle1}" /&gt;
    &lt;/Style&gt;
&lt;/layoutToolkit:Accordion.ItemContainerStyle&gt;
    &lt;layoutToolkit:AccordionItem Content="AccordionItem" /&gt;
    &lt;layoutToolkit:AccordionItem Content="AccordionItem" /&gt;
&lt;/layoutToolkit:Accordion&gt;</pre>
        <p>
(The latter approach is best, imho)
</p>
        <p>
We end up with:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_14.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_6.png" width="391" height="295" />
          </a>
        </p>
        <p>
        </p>
        <p>
I hope that helps!
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=1b37749a-295b-4696-96af-b9d8de1c7fb2" />
      </body>
      <title>Accordion Part 5: AccordionButton</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,1b37749a-295b-4696-96af-b9d8de1c7fb2.aspx</guid>
      <link>http://www.sitechno.com/Blog/AccordionPart5AccordionButton.aspx</link>
      <pubDate>Sat, 11 Apr 2009 20:42:21 GMT</pubDate>
      <description>&lt;p&gt;
I believe this is going to be the last post in this series, although I bet I will
have some loose Accordion posts coming up. This part is going to focus on AccordionButton,
and show you how to retemplate it. 
&lt;/p&gt;
&lt;p&gt;
Previous posts: 
&lt;br /&gt;
&lt;a href="http://www.sitechno.com/Blog/AccordionPart1.aspx" target="_blank"&gt;Part 1&lt;/a&gt; –
accordion 
&lt;br /&gt;
&lt;a href="http://www.sitechno.com/Blog/AccordionPart2.aspx" target="_blank"&gt;Part 2&lt;/a&gt; –
accordion item 
&lt;br /&gt;
&lt;a href="http://www.sitechno.com/Blog/AccordionPart3.aspx" target="_blank"&gt;Part 3&lt;/a&gt; –
expandable content control 
&lt;br /&gt;
&lt;a href="http://www.sitechno.com/Blog/AccordionPart4TemplatingExample.aspx" target="_blank"&gt;Part
4&lt;/a&gt; – retemplating, real world example
&lt;/p&gt;
&lt;p&gt;
We’ve already hit on a lot of the internals of AccordionItem. Expandable content control
was used to easily animate the size of the content. When looking at the header though,
it gets complicated all over again.
&lt;/p&gt;
&lt;p&gt;
This is the important part of AccordionItem, defining both a place for the content
and a place for the header:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;Border x:Name=&amp;quot;Background&amp;quot; 
        Padding=&amp;quot;{TemplateBinding Padding}&amp;quot; 
        BorderBrush=&amp;quot;{TemplateBinding BorderBrush}&amp;quot; 
        BorderThickness=&amp;quot;{TemplateBinding BorderThickness}&amp;quot; 
        CornerRadius=&amp;quot;1,1,1,1&amp;quot;&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;Grid.RowDefinitions&amp;gt;
            &amp;lt;RowDefinition Height=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;rd0&amp;quot;/&amp;gt;
            &amp;lt;RowDefinition Height=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;rd1&amp;quot;/&amp;gt;
        &amp;lt;/Grid.RowDefinitions&amp;gt;
        &amp;lt;Grid.ColumnDefinitions&amp;gt;
            &amp;lt;ColumnDefinition Width=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;cd0&amp;quot;/&amp;gt;
            &amp;lt;ColumnDefinition Width=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;cd1&amp;quot;/&amp;gt;
        &amp;lt;/Grid.ColumnDefinitions&amp;gt;

        &amp;lt;layoutPrimitivesToolkit:AccordionButton
                    x:Name=&amp;quot;ExpanderButton&amp;quot;
          Style=&amp;quot;{TemplateBinding AccordionButtonStyle}&amp;quot;
                    Content=&amp;quot;{TemplateBinding Header}&amp;quot;
                    ContentTemplate=&amp;quot;{TemplateBinding HeaderTemplate}&amp;quot;
                    IsChecked=&amp;quot;{TemplateBinding IsSelected}&amp;quot;
                    IsTabStop=&amp;quot;True&amp;quot;
                    Grid.Row=&amp;quot;0&amp;quot;
                    Padding=&amp;quot;0,0,0,0&amp;quot;
                    Margin=&amp;quot;0,0,0,0&amp;quot;
                    FontFamily=&amp;quot;{TemplateBinding FontFamily}&amp;quot;
                    FontSize=&amp;quot;{TemplateBinding FontSize}&amp;quot;
                    FontStretch=&amp;quot;{TemplateBinding FontStretch}&amp;quot;
                    FontStyle=&amp;quot;{TemplateBinding FontStyle}&amp;quot;
                    FontWeight=&amp;quot;{TemplateBinding FontWeight}&amp;quot;
                    Foreground=&amp;quot;{TemplateBinding Foreground}&amp;quot;
                    VerticalContentAlignment=&amp;quot;{TemplateBinding VerticalContentAlignment}&amp;quot; 
                    HorizontalAlignment=&amp;quot;Stretch&amp;quot;
                    VerticalAlignment=&amp;quot;Stretch&amp;quot; 
          HorizontalContentAlignment=&amp;quot;{TemplateBinding HorizontalContentAlignment}&amp;quot;
          Background=&amp;quot;{TemplateBinding Background}&amp;quot; /&amp;gt;

        &amp;lt;layoutPrimitivesToolkit:ExpandableContentControl
                    x:Name=&amp;quot;ExpandSite&amp;quot;
                    Grid.Row=&amp;quot;1&amp;quot;
                    IsTabStop=&amp;quot;False&amp;quot;
                    Percentage=&amp;quot;0&amp;quot;
                    RevealMode=&amp;quot;{TemplateBinding ExpandDirection}&amp;quot;
                    Content=&amp;quot;{TemplateBinding Content}&amp;quot;
                    ContentTemplate=&amp;quot;{TemplateBinding ContentTemplate}&amp;quot;
                    Margin=&amp;quot;0,0,0,0&amp;quot;
                    FontFamily=&amp;quot;{TemplateBinding FontFamily}&amp;quot;
                    FontSize=&amp;quot;{TemplateBinding FontSize}&amp;quot;
                    FontStretch=&amp;quot;{TemplateBinding FontStretch}&amp;quot;
                    FontStyle=&amp;quot;{TemplateBinding FontStyle}&amp;quot;
                    FontWeight=&amp;quot;{TemplateBinding FontWeight}&amp;quot;
                    Foreground=&amp;quot;{TemplateBinding Foreground}&amp;quot;
                    HorizontalContentAlignment=&amp;quot;Left&amp;quot;
                    VerticalContentAlignment=&amp;quot;Top&amp;quot; 
                    HorizontalAlignment=&amp;quot;Stretch&amp;quot;
                    VerticalAlignment=&amp;quot;Stretch&amp;quot;/&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/Border&amp;gt;&lt;/pre&gt;
&lt;p&gt;
&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see, both ExpandableContentControl and AccordionButton are placed in the
primitives namespace. More importantly, they are placed in a grid. As I’ve shown in
previous posts, that is how we react to the ExpandDirection setting on accordion (so
placing the content in the first column and the button in the second would correspond
to the ExpandDirection ‘right’). 
&lt;/p&gt;
&lt;p&gt;
AccordionButton is an extremely simple class. It inherits from ToggleButton, and its
whole purpose in life is to be able to react (once again) to different ExpandDirections.
So, if you were to open up the code of AccordionButton, you would see that all it
does is this:
&lt;/p&gt;
&lt;pre class="brush: csharp; gutter: false;"&gt;switch (ParentAccordionItem.ExpandDirection)
{
    case ExpandDirection.Down:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandDown);
        break;

    case ExpandDirection.Up:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandUp);
        break;

    case ExpandDirection.Left:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandLeft);
        break;

    default:
        VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandRight);
        break;
}&lt;/pre&gt;
&lt;p&gt;
Ofcourse, the template of AccordionButton is quite big. This is the reason I introduced
this class, just to simplify the template (considerably).
&lt;/p&gt;
&lt;p&gt;
It is time to look at the important part of AccordionButtons template:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;Border x:Name=&amp;quot;background&amp;quot; Background=&amp;quot;{TemplateBinding Background}&amp;quot; CornerRadius=&amp;quot;1,1,1,1&amp;quot;&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;Border Height=&amp;quot;Auto&amp;quot; Margin=&amp;quot;0,0,0,0&amp;quot; x:Name=&amp;quot;ExpandedBackground&amp;quot; VerticalAlignment=&amp;quot;Stretch&amp;quot; Opacity=&amp;quot;0&amp;quot; Background=&amp;quot;#FFBADDE9&amp;quot; BorderBrush=&amp;quot;{TemplateBinding BorderBrush}&amp;quot; BorderThickness=&amp;quot;{TemplateBinding BorderThickness}&amp;quot; CornerRadius=&amp;quot;1,1,1,1&amp;quot;/&amp;gt;
        &amp;lt;Border Height=&amp;quot;Auto&amp;quot; Margin=&amp;quot;0,0,0,0&amp;quot; x:Name=&amp;quot;MouseOverBackground&amp;quot; VerticalAlignment=&amp;quot;Stretch&amp;quot; Opacity=&amp;quot;0&amp;quot; Background=&amp;quot;#FFBDBDBD&amp;quot; BorderBrush=&amp;quot;{TemplateBinding BorderBrush}&amp;quot; BorderThickness=&amp;quot;{TemplateBinding BorderThickness}&amp;quot; CornerRadius=&amp;quot;1,1,1,1&amp;quot;/&amp;gt;
        &amp;lt;Grid Background=&amp;quot;Transparent&amp;quot;&amp;gt;
            &amp;lt;Grid.ColumnDefinitions&amp;gt;
                &amp;lt;ColumnDefinition Width=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;cd0&amp;quot;/&amp;gt;
                &amp;lt;ColumnDefinition Width=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;cd1&amp;quot;/&amp;gt;
            &amp;lt;/Grid.ColumnDefinitions&amp;gt;
            &amp;lt;Grid.RowDefinitions&amp;gt;
                &amp;lt;RowDefinition Height=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;rd0&amp;quot;/&amp;gt;
                &amp;lt;RowDefinition Height=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;rd1&amp;quot;/&amp;gt;
            &amp;lt;/Grid.RowDefinitions&amp;gt;
            &amp;lt;Grid Height=&amp;quot;19&amp;quot; HorizontalAlignment=&amp;quot;Center&amp;quot; x:Name=&amp;quot;icon&amp;quot; VerticalAlignment=&amp;quot;Center&amp;quot; Width=&amp;quot;19&amp;quot; RenderTransformOrigin=&amp;quot;0.5,0.5&amp;quot; Grid.Column=&amp;quot;0&amp;quot; Grid.Row=&amp;quot;0&amp;quot;&amp;gt;
                &amp;lt;Grid.RenderTransform&amp;gt;
                    &amp;lt;TransformGroup&amp;gt;
                        &amp;lt;ScaleTransform/&amp;gt;
                        &amp;lt;SkewTransform/&amp;gt;
                        &amp;lt;RotateTransform Angle=&amp;quot;-90&amp;quot;/&amp;gt;
                        &amp;lt;TranslateTransform/&amp;gt;
                    &amp;lt;/TransformGroup&amp;gt;
                &amp;lt;/Grid.RenderTransform&amp;gt;
                &amp;lt;Path 
                    Height=&amp;quot;Auto&amp;quot; 
                    HorizontalAlignment=&amp;quot;Center&amp;quot; 
                    Margin=&amp;quot;0,0,0,0&amp;quot; x:Name=&amp;quot;arrow&amp;quot; 
                    VerticalAlignment=&amp;quot;Center&amp;quot; 
                    Width=&amp;quot;Auto&amp;quot; 
                    RenderTransformOrigin=&amp;quot;0.5,0.5&amp;quot; 
                    Stroke=&amp;quot;#666&amp;quot; 
                    StrokeThickness=&amp;quot;2&amp;quot; 
                    Data=&amp;quot;M 1,1.5 L 4.5,5 L 8,1.5&amp;quot;&amp;gt;
                    &amp;lt;Path.RenderTransform&amp;gt;
                        &amp;lt;TransformGroup&amp;gt;
                            &amp;lt;ScaleTransform/&amp;gt;
                            &amp;lt;SkewTransform/&amp;gt;
                            &amp;lt;RotateTransform/&amp;gt;
                            &amp;lt;TranslateTransform/&amp;gt;
                        &amp;lt;/TransformGroup&amp;gt;
                    &amp;lt;/Path.RenderTransform&amp;gt;
                &amp;lt;/Path&amp;gt;
            &amp;lt;/Grid&amp;gt;
            &amp;lt;layoutToolkit:LayoutTransformer
                FontFamily=&amp;quot;{TemplateBinding FontFamily}&amp;quot; 
                FontSize=&amp;quot;{TemplateBinding FontSize}&amp;quot; 
                FontStretch=&amp;quot;{TemplateBinding FontStretch}&amp;quot; 
                FontStyle=&amp;quot;{TemplateBinding FontStyle}&amp;quot; 
                FontWeight=&amp;quot;{TemplateBinding FontWeight}&amp;quot; 
                Foreground=&amp;quot;{TemplateBinding Foreground}&amp;quot; 
                HorizontalAlignment=&amp;quot;{TemplateBinding HorizontalContentAlignment}&amp;quot;
                Margin=&amp;quot;6,6,6,0&amp;quot; 
                x:Name=&amp;quot;header&amp;quot; 
                Grid.Column=&amp;quot;0&amp;quot;
                Grid.Row=&amp;quot;0&amp;quot; 
                Grid.RowSpan=&amp;quot;1&amp;quot; 
                Content=&amp;quot;{TemplateBinding Content}&amp;quot; 
                ContentTemplate=&amp;quot;{TemplateBinding ContentTemplate}&amp;quot;/&amp;gt;
        &amp;lt;/Grid&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/Border&amp;gt;&lt;/pre&gt;
&lt;p&gt;
There are two parts here. We have a grid (named ’icon’) and a LayoutTransformer. Again,
we see the old trick of a grid with 2 columns and 2 rows: it is used to place the
icon relative to the header.
&lt;/p&gt;
&lt;p&gt;
Layouttransformer: it is a class that my teammate Delay has developed and was able
to ship with the toolkit. He has a whole host of blog posts about it, and his latest
may be of most interest to you: it shows how to animate the &lt;a href="http://blogs.msdn.com/delay/archive/2009/04/10/a-bit-more-er-than-meets-the-eye-easily-animate-and-update-layouttransformer-with-animationmediator.aspx" target="_blank"&gt;layoutTransformer&lt;/a&gt;. 
&lt;br /&gt;
LayoutTransformer is a control that allows me to rotate the header and keeping the
layout engine happy. In other words, I rotate the header 90 degrees, and the width
and height of the header is correct. That would not be the case if I had used RenderTransform. 
&lt;br /&gt;
I will not focus on this class any more, please checkout Delays posts on it!
&lt;/p&gt;
&lt;p&gt;
By now, you should have enough understanding of what is going on to be able to retemplate
AccordionButton:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
It holds both the Header and an icon&lt;/li&gt;
&lt;li&gt;
It reacts to expanddirection&lt;/li&gt;
&lt;li&gt;
It re-arranges the location of the button and header accordingly&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Actually, it also rotates the icon. So when you are in ExpandDirection ‘right’, the
arrow in the button will still point towards the content, even though its location
is completely different from ExpandDirection ‘left’. 
&lt;/p&gt;
&lt;h5&gt;Templating the AccordionButton
&lt;/h5&gt;
&lt;p&gt;
We have hidden AccordionButton from the designer surface. We did that because we feel
that, as a primitive, there is no value in having AccordionButton clutter up the design
toolbox. However, in order to template it, it is easiest to use blend with only an
AccordionButton there.. So I used this Xaml in Blend:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;UserControl x:Class=&amp;quot;AccordionBlogSamplesSL2.HorizontalImages&amp;quot;
    xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot; 
    xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot; 
    xmlns:layoutToolkit=&amp;quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit&amp;quot; 
    xmlns:vsm=&amp;quot;clr-namespace:System.Windows;assembly=System.Windows&amp;quot; xmlns:System_Windows_Controls_Primitives=&amp;quot;clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit&amp;quot; 
    &amp;gt;
  &amp;lt;Grid x:Name=&amp;quot;LayoutRoot&amp;quot; Background=&amp;quot;White&amp;quot;&amp;gt;
      &amp;lt;System_Windows_Controls_Primitives:AccordionButton /&amp;gt;
  &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;&lt;/pre&gt;
&lt;p&gt;
That gives me a nice design surface with an AccordionButton on it. When I attempt
to ‘Edit template’, Blend will create the style and shows the objects inside of AccordionButton:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb.png" width="251" height="315" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Not only that, it also shows me these states:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_1.png" width="281" height="632" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
When pressing any of the ExpandDirectionStates, you will notice the icon being rotated
and moved to different gridcells. It is easiest to remain in the Base state to do
your work. 
&lt;/p&gt;
&lt;p&gt;
I’m not a terribly good designer (one would argue I am in fact, a terribly bad designer),
so I would even attempt to make this look good. I will just change the template slightly
so I have &lt;em&gt;something&lt;/em&gt; to show you!
&lt;/p&gt;
&lt;p&gt;
The design surface looks like this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_2.png" width="324" height="314" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I will change the path (called arrow) to this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_12.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_5.png" width="217" height="214" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I’ve also changed the MouseOverBackground to something random and the expanded background. 
&lt;br /&gt;
Quite a few people have asked me how to change those properties, well, here they are.
They are part of the AccordionButton template. 
&lt;br /&gt;
&lt;/p&gt;
&lt;h5&gt;Bringing it all together
&lt;/h5&gt;
&lt;p&gt;
AccordionItem luckily exposes an AccordionButtonStyle, so in order to restyle our
AccordionItems to accept this AccordionButtonStyle, we simply apply it.
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;layoutToolkit:Accordion&amp;gt;
    &amp;lt;layoutToolkit:AccordionItem Content=&amp;quot;AccordionItem&amp;quot; AccordionButtonStyle=&amp;quot;{StaticResource AccordionButtonStyle1}&amp;quot;/&amp;gt;
    &amp;lt;layoutToolkit:AccordionItem Content=&amp;quot;AccordionItem&amp;quot; AccordionButtonStyle=&amp;quot;{StaticResource AccordionButtonStyle1}&amp;quot;/&amp;gt;
&amp;lt;/layoutToolkit:Accordion&amp;gt;&lt;/pre&gt;
&lt;p&gt;
As I’ve been getting some questions on my blog about styles and templates, I will
also show you how to do this with an AccordionItemContainerStyle:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;layoutToolkit:Accordion&amp;gt;
&amp;lt;layoutToolkit:Accordion.ItemContainerStyle&amp;gt;
    &amp;lt;Style TargetType=&amp;quot;layoutToolkit:AccordionItem&amp;quot;&amp;gt;
     &amp;lt;Setter Property=&amp;quot;AccordionButtonStyle&amp;quot; Value=&amp;quot;{StaticResource AccordionButtonStyle1}&amp;quot; /&amp;gt;
    &amp;lt;/Style&amp;gt;
&amp;lt;/layoutToolkit:Accordion.ItemContainerStyle&amp;gt;
    &amp;lt;layoutToolkit:AccordionItem Content=&amp;quot;AccordionItem&amp;quot; /&amp;gt;
    &amp;lt;layoutToolkit:AccordionItem Content=&amp;quot;AccordionItem&amp;quot; /&amp;gt;
&amp;lt;/layoutToolkit:Accordion&amp;gt;&lt;/pre&gt;
&lt;p&gt;
(The latter approach is best, imho)
&lt;/p&gt;
&lt;p&gt;
We end up with:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_14.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart5AccordionButton_C07E/image_thumb_6.png" width="391" height="295" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
I hope that helps!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=1b37749a-295b-4696-96af-b9d8de1c7fb2" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,1b37749a-295b-4696-96af-b9d8de1c7fb2.aspx</comments>
      <category>Silverlight;Silverlight Toolkit</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=cba88585-5aff-4cc8-b00a-9e38c440df49</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,cba88585-5aff-4cc8-b00a-9e38c440df49.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,cba88585-5aff-4cc8-b00a-9e38c440df49.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=cba88585-5aff-4cc8-b00a-9e38c440df49</wfw:commentRss>
      <slash:comments>52</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Mehdi pointed me to a great accordion on <a href="http://video.msn.com/video.aspx/?mkt=en-us&amp;vid=3b5a1842-14b8-488d-91eb-1be1d02b8cda&amp;wa=wsignin1.0" target="_blank">this
site</a>. It is a horizontal accordion that only uses images. In this post I’ll walk
us through creating something similar. 
</p>
        <p>
This is what the accordion looks like:<a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb.png" width="604" height="218" /></a></p>
        <p>
There is a snazzy effect where the headline pops in from below when you open the item.
Go look at it and play a bit, it’s pretty cool!
</p>
        <p>
I started out by adding references to the highlighted 3 dll’s. All 3 are necessary!
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_1.png" width="296" height="198" />
          </a>
        </p>
        <p>
Then I created my accordion and gave it some fixed size accordion items. I used this
Xaml:
</p>
        <pre class="brush: xml; gutter: false;">    &lt;layoutToolkit:Accordion ExpandDirection="Right" Margin="100"&gt;
      &lt;layoutToolkit:AccordionItem&gt;
        &lt;Rectangle Width="150" Height="80" Fill="Blue" /&gt;
      &lt;/layoutToolkit:AccordionItem&gt;
      &lt;layoutToolkit:AccordionItem&gt;
        &lt;Rectangle Width="150" Height="80" Fill="Red" /&gt;
      &lt;/layoutToolkit:AccordionItem&gt;
      &lt;layoutToolkit:AccordionItem&gt;
        &lt;Rectangle Width="150" Height="80" Fill="Green" /&gt;
      &lt;/layoutToolkit:AccordionItem&gt;
      &lt;layoutToolkit:AccordionItem&gt;
        &lt;Rectangle Width="150" Height="80" Fill="Yellow" /&gt;
      &lt;/layoutToolkit:AccordionItem&gt;
      &lt;layoutToolkit:AccordionItem&gt;
        &lt;Rectangle Width="150" Height="80" Fill="PowderBlue" /&gt;
      &lt;/layoutToolkit:AccordionItem&gt;
    &lt;/layoutToolkit:Accordion&gt;</pre>
        <p>
        </p>
        <p>
As you can see, I set the ExpandDirection to “Right”, so the accordion opens up in
the same way as our sample. I have not set a specific Width on the Accordion, which
means that the Accordion will only take what it needs.
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_2.png" width="275" height="98" />
          </a>
        </p>
        <p>
I get a lot of questions on how the Width of the Accordion determines sizing on AccordionItems.
You need to remember that the Items will always divide the space <strong>equally</strong> they
get. In our example, setting a fixed Width of 500 on the Accordion would have yielded
this result:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_3.png" width="519" height="104" />
          </a>
        </p>
        <p>
Now, our AccordionItems exist always of a header and content. In our sample though,
we do not see a header at all. So, we will need to retemplate AccordionItem in order
to remove that header. 
<br />
There is a headerTemplate property on Accordion, but keep in mind that that will allow
you to determine the look of what goes into the header! In our case, we will completely
remove the header from AccordionItem. So, I went into Blend and selected the first
AccordionItem and opened up its template:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_10.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_4.png" width="470" height="465" />
          </a>
        </p>
        <p>
This created a styleResource that is being applied to the first item. 
<br />
In the template, I removed every element that I don’t care about. The AccordionButton
is the little arrow that moves. Leaving me with this:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_12.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_5.png" width="273" height="172" />
          </a>
        </p>
        <p>
However, we do actually <strong>need</strong> a header, since it will be the element
a user can click to navigate the accordion. So, let’s look at the Grid that hosts
ExpandSite:
</p>
        <pre class="brush: xml; gutter: false;">&lt;Grid&gt;
&lt;Grid.RowDefinitions&gt;
    &lt;RowDefinition Height="Auto" x:Name="rd0"/&gt;
    &lt;RowDefinition Height="Auto" x:Name="rd1"/&gt;
&lt;/Grid.RowDefinitions&gt;
&lt;Grid.ColumnDefinitions&gt;
    &lt;ColumnDefinition Width="Auto" x:Name="cd0"/&gt;
    &lt;ColumnDefinition Width="Auto" x:Name="cd1"/&gt;
&lt;/Grid.ColumnDefinitions&gt;
&lt;System_Windows_Controls_Primitives:ExpandableContentControl 
        HorizontalAlignment="Stretch" 
        Margin="0,0,0,0" 
        x:Name="ExpandSite" 
        VerticalAlignment="Stretch" 
        Grid.Row="1" 
        FontFamily="{TemplateBinding FontFamily}" 
        FontSize="{TemplateBinding FontSize}" 
        FontStretch="{TemplateBinding FontStretch}" 
        FontStyle="{TemplateBinding FontStyle}" 
        FontWeight="{TemplateBinding FontWeight}" 
        Foreground="{TemplateBinding Foreground}" 
        HorizontalContentAlignment="Left" 
        IsTabStop="False" 
        VerticalContentAlignment="Top" 
        Content="{TemplateBinding Content}" 
        ContentTemplate="{TemplateBinding ContentTemplate}" 
        Percentage="0" 
        RevealMode="{TemplateBinding ExpandDirection}"/&gt;
&lt;/Grid&gt;</pre>
        <p>
You can see that the grid has 2 rows and 2 columns. This is all that is needed to
position the header and content in all the possible expandDirections. Just for fun,
I’ll show you the VisualState “ExpandedRight”:
</p>
        <pre class="brush: xml; gutter: false;">&lt;vsm:VisualState x:Name="ExpandRight"&gt;
    &lt;Storyboard&gt;
        &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(Grid.ColumnSpan)"&gt;
            &lt;DiscreteObjectKeyFrame KeyTime="0" Value="1"/&gt;
        &lt;/ObjectAnimationUsingKeyFrames&gt;
        &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(Grid.RowSpan)"&gt;
            &lt;DiscreteObjectKeyFrame KeyTime="0" Value="2"/&gt;
        &lt;/ObjectAnimationUsingKeyFrames&gt;
        &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(Grid.Row)"&gt;
            &lt;DiscreteObjectKeyFrame KeyTime="0" Value="0"/&gt;
        &lt;/ObjectAnimationUsingKeyFrames&gt;
        &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(Grid.Column)"&gt;
            &lt;DiscreteObjectKeyFrame KeyTime="0" Value="1"/&gt;
        &lt;/ObjectAnimationUsingKeyFrames&gt;
        &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="rd0" Storyboard.TargetProperty="Height"&gt;
            &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt;
        &lt;/ObjectAnimationUsingKeyFrames&gt;
        &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd1" Storyboard.TargetProperty="Width"&gt;
            &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt;
        &lt;/ObjectAnimationUsingKeyFrames&gt;
    &lt;/Storyboard&gt;
&lt;/vsm:VisualState&gt;</pre>
        <p>
As you can see, it is happily placing items in the correct location and setting heights
and widths on the grid cells. Since we do want the header to have a width, I’ll give
the first column (where our header would have been) a minWidth. I will also remove
all the Expand visualstates since I don’t need those and they only serve to bloat
the Xaml at this point.
</p>
        <p>
Since we removed AccordionButton, we have nothing to press and open the Item. But
that’s not what we want anyway, we want to open items as we mouse over them. So I’ve
introduced an eventhandler for the MouseEnter event on AccordionItem:
</p>
        <pre class="brush: csharp; gutter: false;">void item_MouseEnter(object sender, MouseEventArgs e)
{
    AccordionItem item = (AccordionItem) sender;
    item.IsSelected = true;
}</pre>
        <p>
Now we’re getting somewhere! The items behave quite similar to our sample. Still need
to figure out the header and content parts though. The ExpandSite will always contract
to 0 width when it is collapsed (not selected). That can’t be what we want.
</p>
        <p>
We removed the header because we did not want it, and want a part of the content to
be visible. There are two animations that govern the expand and collapse movements.
They are here:
</p>
        <pre class="brush: xml; gutter: false;">&lt;vsm:VisualStateGroup x:Name="ExpansionStates"&gt;
    &lt;vsm:VisualStateGroup.Transitions&gt;
        &lt;vsm:VisualTransition GeneratedDuration="0"/&gt;
    &lt;/vsm:VisualStateGroup.Transitions&gt;
    &lt;vsm:VisualState x:Name="Collapsed"&gt;
        &lt;Storyboard&gt;
            &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)"&gt;
                &lt;SplineDoubleKeyFrame KeySpline="0.2,0,0,1" KeyTime="00:00:00.3" <strong>Value="0"/</strong>&gt;
&lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt;
&lt;vsm:VisualState x:Name="Expanded"&gt; &lt;Storyboard&gt; &lt;DoubleAnimationUsingKeyFrames
BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)"&gt;
&lt;SplineDoubleKeyFrame KeySpline="0.2,0,0,1" KeyTime="00:00:00.3"
Value="1"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt;
&lt;/vsm:VisualState&gt; &lt;/vsm:VisualStateGroup&gt;</pre>
        <br />
        <p>
Let me explain what is going on there. An AccordionItem can be in either Collapsed
or Expanded state. I have no way of determining how big an item should be when it
is expanded. Remember, it is the accordion that calculates such things at runtime
(given the amount of items, and the width of the accordion itself). When the accordion
sets a ‘targetsize’, we also calculate a percentage. When we are collapsed, that percentage
is 0, when we are fully expanded, that percentage is 1. 
</p>
        <p>
The storyboards that you can see here are being started after the AccordionItem has
been collapsed or expanded. In other words, they actually do the revealing or hiding
of the content. The only thing they have to animate is the percentage, and this way
I allow designers to come in and create different kind of animations (changing the
keyspline for instance). 
</p>
        <p>
The important value here is 0, in the Collapsed storyboard. Turns out we don’t want
it to collapse to 0, but to something like 0.2! If we change that storyboard, the
item will still be partially visible, even though the accordion feels it is completely
collapsed. 
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_14.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_6.png" width="480" height="172" />
          </a>
        </p>
        <p>
That was easy. So, let’s start working on some cool headline action. 
<br />
I’d like to have a headline come in from below as we expand.
</p>
        <p>
So, let’s create a ContentControl to display our header:
</p>
        <pre class="brush: xml; gutter: false;">                        &lt;Grid&gt;
                            &lt;System_Windows_Controls_Primitives:ExpandableContentControl 
                                HorizontalAlignment="Stretch" 
                                Margin="0,0,0,0" 
                                x:Name="ExpandSite" 
                                VerticalAlignment="Stretch" 
                                HorizontalContentAlignment="Left" 
                                IsTabStop="False" 
                                VerticalContentAlignment="Top" 
                                Content="{TemplateBinding Content}" 
                                ContentTemplate="{TemplateBinding ContentTemplate}" 
                                Percentage="0" 
                                RevealMode="{TemplateBinding ExpandDirection}"/&gt;
                            &lt;ContentControl x:Name="header" 
                                Content="{TemplateBinding Header}" 
                          VerticalAlignment="Bottom" 
                          Visibility="Collapsed" RenderTransformOrigin="0.5,0.5" &gt;
                                &lt;ContentControl.RenderTransform&gt;
                                    &lt;TransformGroup&gt;
                                        &lt;ScaleTransform/&gt;
                                        &lt;SkewTransform/&gt;
                                        &lt;RotateTransform/&gt;
                                        &lt;TranslateTransform/&gt;
                                    &lt;/TransformGroup&gt;
                                &lt;/ContentControl.RenderTransform&gt;
                            &lt;/ContentControl&gt;
                        &lt;/Grid&gt;
                    &lt;/Border&gt;
                &lt;/Grid&gt;</pre>
        <p>
And have Blend generate some nice animation effects:
</p>
        <pre class="brush: xml; gutter: false;">&lt;vsm:VisualState x:Name="Expanded"&gt;
&lt;Storyboard&gt;
    &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)"&gt;
        &lt;SplineDoubleKeyFrame KeySpline="0.2,0,0,1" KeyTime="00:00:00.3" Value="1"/&gt;
    &lt;/DoubleAnimationUsingKeyFrames&gt;
    &lt;ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="header" Storyboard.TargetProperty="(UIElement.Visibility)"&gt;
        &lt;DiscreteObjectKeyFrame KeyTime="00:00:00.2000000"&gt;
            &lt;DiscreteObjectKeyFrame.Value&gt;
                &lt;Visibility&gt;Visible&lt;/Visibility&gt;
            &lt;/DiscreteObjectKeyFrame.Value&gt;
        &lt;/DiscreteObjectKeyFrame&gt;
    &lt;/ObjectAnimationUsingKeyFrames&gt;
    &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="header" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"&gt;
        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="60"/&gt;
        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" KeySpline="0,0,0.46900001168251,1"/&gt;
    &lt;/DoubleAnimationUsingKeyFrames&gt;
&lt;/Storyboard&gt;</pre>
        <p>
You can see that the header starts out with Visibility=Collapsed, this way it won’t
take up any space and mess up the AccordionItem. 
<br />
When the item expands, that visibility is toggled and a rendertransform is used to
bring it into view. 
</p>
        <p>
Let’s finish it off with some images, to make our accordion look nice! I grabbed some
images and created a somewhat better header:
</p>
        <pre class="brush: xml; gutter: false;">  &lt;layoutToolkit:AccordionItem Style="{StaticResource AccordionItemStyle1}" MouseEnter="item_MouseEnter"&gt;
  &lt;layoutToolkit:AccordionItem.Header&gt;
    &lt;Border Background="#aa000000" Width="400" Height="80"&gt;
      &lt;StackPanel Margin="10"&gt;
        &lt;TextBlock FontFamily="Verdana" FontSize="20" Foreground="White"&gt;Seamonster&lt;/TextBlock&gt; 
        &lt;TextBlock FontFamily="Verdana" FontSize="12" Foreground="White"&gt;by Proudlove&lt;/TextBlock&gt; 
      &lt;/StackPanel&gt;
    &lt;/Border&gt;
  &lt;/layoutToolkit:AccordionItem.Header&gt;
  &lt;Image Source="/Images/3410783929_051d93bc86.jpg"  /&gt;
&lt;/layoutToolkit:AccordionItem&gt;</pre>
        <p>
I also changed the animations slightly, to be somewhat slower. The result looks like
this:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_16.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_7.png" width="661" height="284" />
          </a>
        </p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_18.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_8.png" width="658" height="278" />
          </a>
        </p>
        <p>
I hope this little walkthrough helped.
</p>
        <p>
See the live sample <a href="http://www.sitechno.com/Silverlight/AccordionHorizontalImages/AccordionHorizontalImages.html" target="_blank">here</a>,
and download the project <a href="http://www.sitechno.com/Silverlight/AccordionHorizontalImages/AccordionHorizontalImages.zip" target="_blank">here</a>. 
<br />
Let me know what you think!
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=cba88585-5aff-4cc8-b00a-9e38c440df49" />
      </body>
      <title>Accordion Part 4 templating example</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,cba88585-5aff-4cc8-b00a-9e38c440df49.aspx</guid>
      <link>http://www.sitechno.com/Blog/AccordionPart4TemplatingExample.aspx</link>
      <pubDate>Mon, 06 Apr 2009 03:37:46 GMT</pubDate>
      <description>&lt;p&gt;
Mehdi pointed me to a great accordion on &lt;a href="http://video.msn.com/video.aspx/?mkt=en-us&amp;amp;vid=3b5a1842-14b8-488d-91eb-1be1d02b8cda&amp;amp;wa=wsignin1.0" target="_blank"&gt;this
site&lt;/a&gt;. It is a horizontal accordion that only uses images. In this post I’ll walk
us through creating something similar. 
&lt;/p&gt;
&lt;p&gt;
This is what the accordion looks like:&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb.png" width="604" height="218" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
There is a snazzy effect where the headline pops in from below when you open the item.
Go look at it and play a bit, it’s pretty cool!
&lt;/p&gt;
&lt;p&gt;
I started out by adding references to the highlighted 3 dll’s. All 3 are necessary!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_1.png" width="296" height="198" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Then I created my accordion and gave it some fixed size accordion items. I used this
Xaml:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;    &amp;lt;layoutToolkit:Accordion ExpandDirection=&amp;quot;Right&amp;quot; Margin=&amp;quot;100&amp;quot;&amp;gt;
      &amp;lt;layoutToolkit:AccordionItem&amp;gt;
        &amp;lt;Rectangle Width=&amp;quot;150&amp;quot; Height=&amp;quot;80&amp;quot; Fill=&amp;quot;Blue&amp;quot; /&amp;gt;
      &amp;lt;/layoutToolkit:AccordionItem&amp;gt;
      &amp;lt;layoutToolkit:AccordionItem&amp;gt;
        &amp;lt;Rectangle Width=&amp;quot;150&amp;quot; Height=&amp;quot;80&amp;quot; Fill=&amp;quot;Red&amp;quot; /&amp;gt;
      &amp;lt;/layoutToolkit:AccordionItem&amp;gt;
      &amp;lt;layoutToolkit:AccordionItem&amp;gt;
        &amp;lt;Rectangle Width=&amp;quot;150&amp;quot; Height=&amp;quot;80&amp;quot; Fill=&amp;quot;Green&amp;quot; /&amp;gt;
      &amp;lt;/layoutToolkit:AccordionItem&amp;gt;
      &amp;lt;layoutToolkit:AccordionItem&amp;gt;
        &amp;lt;Rectangle Width=&amp;quot;150&amp;quot; Height=&amp;quot;80&amp;quot; Fill=&amp;quot;Yellow&amp;quot; /&amp;gt;
      &amp;lt;/layoutToolkit:AccordionItem&amp;gt;
      &amp;lt;layoutToolkit:AccordionItem&amp;gt;
        &amp;lt;Rectangle Width=&amp;quot;150&amp;quot; Height=&amp;quot;80&amp;quot; Fill=&amp;quot;PowderBlue&amp;quot; /&amp;gt;
      &amp;lt;/layoutToolkit:AccordionItem&amp;gt;
    &amp;lt;/layoutToolkit:Accordion&amp;gt;&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see, I set the ExpandDirection to “Right”, so the accordion opens up in
the same way as our sample. I have not set a specific Width on the Accordion, which
means that the Accordion will only take what it needs.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_2.png" width="275" height="98" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I get a lot of questions on how the Width of the Accordion determines sizing on AccordionItems.
You need to remember that the Items will always divide the space &lt;strong&gt;equally&lt;/strong&gt; they
get. In our example, setting a fixed Width of 500 on the Accordion would have yielded
this result:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_3.png" width="519" height="104" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Now, our AccordionItems exist always of a header and content. In our sample though,
we do not see a header at all. So, we will need to retemplate AccordionItem in order
to remove that header. 
&lt;br /&gt;
There is a headerTemplate property on Accordion, but keep in mind that that will allow
you to determine the look of what goes into the header! In our case, we will completely
remove the header from AccordionItem. So, I went into Blend and selected the first
AccordionItem and opened up its template:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_4.png" width="470" height="465" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
This created a styleResource that is being applied to the first item. 
&lt;br /&gt;
In the template, I removed every element that I don’t care about. The AccordionButton
is the little arrow that moves. Leaving me with this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_5.png" width="273" height="172" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
However, we do actually &lt;strong&gt;need&lt;/strong&gt; a header, since it will be the element
a user can click to navigate the accordion. So, let’s look at the Grid that hosts
ExpandSite:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;Grid&amp;gt;
&amp;lt;Grid.RowDefinitions&amp;gt;
    &amp;lt;RowDefinition Height=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;rd0&amp;quot;/&amp;gt;
    &amp;lt;RowDefinition Height=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;rd1&amp;quot;/&amp;gt;
&amp;lt;/Grid.RowDefinitions&amp;gt;
&amp;lt;Grid.ColumnDefinitions&amp;gt;
    &amp;lt;ColumnDefinition Width=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;cd0&amp;quot;/&amp;gt;
    &amp;lt;ColumnDefinition Width=&amp;quot;Auto&amp;quot; x:Name=&amp;quot;cd1&amp;quot;/&amp;gt;
&amp;lt;/Grid.ColumnDefinitions&amp;gt;
&amp;lt;System_Windows_Controls_Primitives:ExpandableContentControl 
        HorizontalAlignment=&amp;quot;Stretch&amp;quot; 
        Margin=&amp;quot;0,0,0,0&amp;quot; 
        x:Name=&amp;quot;ExpandSite&amp;quot; 
        VerticalAlignment=&amp;quot;Stretch&amp;quot; 
        Grid.Row=&amp;quot;1&amp;quot; 
        FontFamily=&amp;quot;{TemplateBinding FontFamily}&amp;quot; 
        FontSize=&amp;quot;{TemplateBinding FontSize}&amp;quot; 
        FontStretch=&amp;quot;{TemplateBinding FontStretch}&amp;quot; 
        FontStyle=&amp;quot;{TemplateBinding FontStyle}&amp;quot; 
        FontWeight=&amp;quot;{TemplateBinding FontWeight}&amp;quot; 
        Foreground=&amp;quot;{TemplateBinding Foreground}&amp;quot; 
        HorizontalContentAlignment=&amp;quot;Left&amp;quot; 
        IsTabStop=&amp;quot;False&amp;quot; 
        VerticalContentAlignment=&amp;quot;Top&amp;quot; 
        Content=&amp;quot;{TemplateBinding Content}&amp;quot; 
        ContentTemplate=&amp;quot;{TemplateBinding ContentTemplate}&amp;quot; 
        Percentage=&amp;quot;0&amp;quot; 
        RevealMode=&amp;quot;{TemplateBinding ExpandDirection}&amp;quot;/&amp;gt;
&amp;lt;/Grid&amp;gt;&lt;/pre&gt;
&lt;p&gt;
You can see that the grid has 2 rows and 2 columns. This is all that is needed to
position the header and content in all the possible expandDirections. Just for fun,
I’ll show you the VisualState “ExpandedRight”:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;vsm:VisualState x:Name=&amp;quot;ExpandRight&amp;quot;&amp;gt;
    &amp;lt;Storyboard&amp;gt;
        &amp;lt;ObjectAnimationUsingKeyFrames Duration=&amp;quot;0&amp;quot; Storyboard.TargetName=&amp;quot;ExpandSite&amp;quot; Storyboard.TargetProperty=&amp;quot;(Grid.ColumnSpan)&amp;quot;&amp;gt;
            &amp;lt;DiscreteObjectKeyFrame KeyTime=&amp;quot;0&amp;quot; Value=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;/ObjectAnimationUsingKeyFrames&amp;gt;
        &amp;lt;ObjectAnimationUsingKeyFrames Duration=&amp;quot;0&amp;quot; Storyboard.TargetName=&amp;quot;ExpandSite&amp;quot; Storyboard.TargetProperty=&amp;quot;(Grid.RowSpan)&amp;quot;&amp;gt;
            &amp;lt;DiscreteObjectKeyFrame KeyTime=&amp;quot;0&amp;quot; Value=&amp;quot;2&amp;quot;/&amp;gt;
        &amp;lt;/ObjectAnimationUsingKeyFrames&amp;gt;
        &amp;lt;ObjectAnimationUsingKeyFrames Duration=&amp;quot;0&amp;quot; Storyboard.TargetName=&amp;quot;ExpandSite&amp;quot; Storyboard.TargetProperty=&amp;quot;(Grid.Row)&amp;quot;&amp;gt;
            &amp;lt;DiscreteObjectKeyFrame KeyTime=&amp;quot;0&amp;quot; Value=&amp;quot;0&amp;quot;/&amp;gt;
        &amp;lt;/ObjectAnimationUsingKeyFrames&amp;gt;
        &amp;lt;ObjectAnimationUsingKeyFrames Duration=&amp;quot;0&amp;quot; Storyboard.TargetName=&amp;quot;ExpandSite&amp;quot; Storyboard.TargetProperty=&amp;quot;(Grid.Column)&amp;quot;&amp;gt;
            &amp;lt;DiscreteObjectKeyFrame KeyTime=&amp;quot;0&amp;quot; Value=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;/ObjectAnimationUsingKeyFrames&amp;gt;
        &amp;lt;ObjectAnimationUsingKeyFrames Duration=&amp;quot;0&amp;quot; Storyboard.TargetName=&amp;quot;rd0&amp;quot; Storyboard.TargetProperty=&amp;quot;Height&amp;quot;&amp;gt;
            &amp;lt;DiscreteObjectKeyFrame KeyTime=&amp;quot;0&amp;quot; Value=&amp;quot;*&amp;quot;/&amp;gt;
        &amp;lt;/ObjectAnimationUsingKeyFrames&amp;gt;
        &amp;lt;ObjectAnimationUsingKeyFrames Duration=&amp;quot;0&amp;quot; Storyboard.TargetName=&amp;quot;cd1&amp;quot; Storyboard.TargetProperty=&amp;quot;Width&amp;quot;&amp;gt;
            &amp;lt;DiscreteObjectKeyFrame KeyTime=&amp;quot;0&amp;quot; Value=&amp;quot;*&amp;quot;/&amp;gt;
        &amp;lt;/ObjectAnimationUsingKeyFrames&amp;gt;
    &amp;lt;/Storyboard&amp;gt;
&amp;lt;/vsm:VisualState&amp;gt;&lt;/pre&gt;
&lt;p&gt;
As you can see, it is happily placing items in the correct location and setting heights
and widths on the grid cells. Since we do want the header to have a width, I’ll give
the first column (where our header would have been) a minWidth. I will also remove
all the Expand visualstates since I don’t need those and they only serve to bloat
the Xaml at this point.
&lt;/p&gt;
&lt;p&gt;
Since we removed AccordionButton, we have nothing to press and open the Item. But
that’s not what we want anyway, we want to open items as we mouse over them. So I’ve
introduced an eventhandler for the MouseEnter event on AccordionItem:
&lt;/p&gt;
&lt;pre class="brush: csharp; gutter: false;"&gt;void item_MouseEnter(object sender, MouseEventArgs e)
{
    AccordionItem item = (AccordionItem) sender;
    item.IsSelected = true;
}&lt;/pre&gt;
&lt;p&gt;
Now we’re getting somewhere! The items behave quite similar to our sample. Still need
to figure out the header and content parts though. The ExpandSite will always contract
to 0 width when it is collapsed (not selected). That can’t be what we want.
&lt;/p&gt;
&lt;p&gt;
We removed the header because we did not want it, and want a part of the content to
be visible. There are two animations that govern the expand and collapse movements.
They are here:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;vsm:VisualStateGroup x:Name=&amp;quot;ExpansionStates&amp;quot;&amp;gt;
    &amp;lt;vsm:VisualStateGroup.Transitions&amp;gt;
        &amp;lt;vsm:VisualTransition GeneratedDuration=&amp;quot;0&amp;quot;/&amp;gt;
    &amp;lt;/vsm:VisualStateGroup.Transitions&amp;gt;
    &amp;lt;vsm:VisualState x:Name=&amp;quot;Collapsed&amp;quot;&amp;gt;
        &amp;lt;Storyboard&amp;gt;
            &amp;lt;DoubleAnimationUsingKeyFrames BeginTime=&amp;quot;00:00:00&amp;quot; Storyboard.TargetName=&amp;quot;ExpandSite&amp;quot; Storyboard.TargetProperty=&amp;quot;(ExpandableContentControl.Percentage)&amp;quot;&amp;gt;
                &amp;lt;SplineDoubleKeyFrame KeySpline=&amp;quot;0.2,0,0,1&amp;quot; KeyTime=&amp;quot;00:00:00.3&amp;quot; &lt;strong&gt;Value=&amp;quot;0&amp;quot;/&lt;/strong&gt;&amp;gt;
&amp;lt;/DoubleAnimationUsingKeyFrames&amp;gt; &amp;lt;/Storyboard&amp;gt; &amp;lt;/vsm:VisualState&amp;gt;
&amp;lt;vsm:VisualState x:Name=&amp;quot;Expanded&amp;quot;&amp;gt; &amp;lt;Storyboard&amp;gt; &amp;lt;DoubleAnimationUsingKeyFrames
BeginTime=&amp;quot;00:00:00&amp;quot; Storyboard.TargetName=&amp;quot;ExpandSite&amp;quot; Storyboard.TargetProperty=&amp;quot;(ExpandableContentControl.Percentage)&amp;quot;&amp;gt;
&amp;lt;SplineDoubleKeyFrame KeySpline=&amp;quot;0.2,0,0,1&amp;quot; KeyTime=&amp;quot;00:00:00.3&amp;quot;
Value=&amp;quot;1&amp;quot;/&amp;gt; &amp;lt;/DoubleAnimationUsingKeyFrames&amp;gt; &amp;lt;/Storyboard&amp;gt;
&amp;lt;/vsm:VisualState&amp;gt; &amp;lt;/vsm:VisualStateGroup&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;p&gt;
Let me explain what is going on there. An AccordionItem can be in either Collapsed
or Expanded state. I have no way of determining how big an item should be when it
is expanded. Remember, it is the accordion that calculates such things at runtime
(given the amount of items, and the width of the accordion itself). When the accordion
sets a ‘targetsize’, we also calculate a percentage. When we are collapsed, that percentage
is 0, when we are fully expanded, that percentage is 1. 
&lt;/p&gt;
&lt;p&gt;
The storyboards that you can see here are being started after the AccordionItem has
been collapsed or expanded. In other words, they actually do the revealing or hiding
of the content. The only thing they have to animate is the percentage, and this way
I allow designers to come in and create different kind of animations (changing the
keyspline for instance). 
&lt;/p&gt;
&lt;p&gt;
The important value here is 0, in the Collapsed storyboard. Turns out we don’t want
it to collapse to 0, but to something like 0.2! If we change that storyboard, the
item will still be partially visible, even though the accordion feels it is completely
collapsed. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_6.png" width="480" height="172" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
That was easy. So, let’s start working on some cool headline action. 
&lt;br /&gt;
I’d like to have a headline come in from below as we expand.
&lt;/p&gt;
&lt;p&gt;
So, let’s create a ContentControl to display our header:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;                        &amp;lt;Grid&amp;gt;
                            &amp;lt;System_Windows_Controls_Primitives:ExpandableContentControl 
                                HorizontalAlignment=&amp;quot;Stretch&amp;quot; 
                                Margin=&amp;quot;0,0,0,0&amp;quot; 
                                x:Name=&amp;quot;ExpandSite&amp;quot; 
                                VerticalAlignment=&amp;quot;Stretch&amp;quot; 
                                HorizontalContentAlignment=&amp;quot;Left&amp;quot; 
                                IsTabStop=&amp;quot;False&amp;quot; 
                                VerticalContentAlignment=&amp;quot;Top&amp;quot; 
                                Content=&amp;quot;{TemplateBinding Content}&amp;quot; 
                                ContentTemplate=&amp;quot;{TemplateBinding ContentTemplate}&amp;quot; 
                                Percentage=&amp;quot;0&amp;quot; 
                                RevealMode=&amp;quot;{TemplateBinding ExpandDirection}&amp;quot;/&amp;gt;
                            &amp;lt;ContentControl x:Name=&amp;quot;header&amp;quot; 
                                Content=&amp;quot;{TemplateBinding Header}&amp;quot; 
                          VerticalAlignment=&amp;quot;Bottom&amp;quot; 
                          Visibility=&amp;quot;Collapsed&amp;quot; RenderTransformOrigin=&amp;quot;0.5,0.5&amp;quot; &amp;gt;
                                &amp;lt;ContentControl.RenderTransform&amp;gt;
                                    &amp;lt;TransformGroup&amp;gt;
                                        &amp;lt;ScaleTransform/&amp;gt;
                                        &amp;lt;SkewTransform/&amp;gt;
                                        &amp;lt;RotateTransform/&amp;gt;
                                        &amp;lt;TranslateTransform/&amp;gt;
                                    &amp;lt;/TransformGroup&amp;gt;
                                &amp;lt;/ContentControl.RenderTransform&amp;gt;
                            &amp;lt;/ContentControl&amp;gt;
                        &amp;lt;/Grid&amp;gt;
                    &amp;lt;/Border&amp;gt;
                &amp;lt;/Grid&amp;gt;&lt;/pre&gt;
&lt;p&gt;
And have Blend generate some nice animation effects:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;&amp;lt;vsm:VisualState x:Name=&amp;quot;Expanded&amp;quot;&amp;gt;
&amp;lt;Storyboard&amp;gt;
    &amp;lt;DoubleAnimationUsingKeyFrames BeginTime=&amp;quot;00:00:00&amp;quot; Storyboard.TargetName=&amp;quot;ExpandSite&amp;quot; Storyboard.TargetProperty=&amp;quot;(ExpandableContentControl.Percentage)&amp;quot;&amp;gt;
        &amp;lt;SplineDoubleKeyFrame KeySpline=&amp;quot;0.2,0,0,1&amp;quot; KeyTime=&amp;quot;00:00:00.3&amp;quot; Value=&amp;quot;1&amp;quot;/&amp;gt;
    &amp;lt;/DoubleAnimationUsingKeyFrames&amp;gt;
    &amp;lt;ObjectAnimationUsingKeyFrames BeginTime=&amp;quot;00:00:00&amp;quot; Storyboard.TargetName=&amp;quot;header&amp;quot; Storyboard.TargetProperty=&amp;quot;(UIElement.Visibility)&amp;quot;&amp;gt;
        &amp;lt;DiscreteObjectKeyFrame KeyTime=&amp;quot;00:00:00.2000000&amp;quot;&amp;gt;
            &amp;lt;DiscreteObjectKeyFrame.Value&amp;gt;
                &amp;lt;Visibility&amp;gt;Visible&amp;lt;/Visibility&amp;gt;
            &amp;lt;/DiscreteObjectKeyFrame.Value&amp;gt;
        &amp;lt;/DiscreteObjectKeyFrame&amp;gt;
    &amp;lt;/ObjectAnimationUsingKeyFrames&amp;gt;
    &amp;lt;DoubleAnimationUsingKeyFrames BeginTime=&amp;quot;00:00:00&amp;quot; Storyboard.TargetName=&amp;quot;header&amp;quot; Storyboard.TargetProperty=&amp;quot;(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)&amp;quot;&amp;gt;
        &amp;lt;SplineDoubleKeyFrame KeyTime=&amp;quot;00:00:00.2000000&amp;quot; Value=&amp;quot;60&amp;quot;/&amp;gt;
        &amp;lt;SplineDoubleKeyFrame KeyTime=&amp;quot;00:00:00.4000000&amp;quot; Value=&amp;quot;0&amp;quot; KeySpline=&amp;quot;0,0,0.46900001168251,1&amp;quot;/&amp;gt;
    &amp;lt;/DoubleAnimationUsingKeyFrames&amp;gt;
&amp;lt;/Storyboard&amp;gt;&lt;/pre&gt;
&lt;p&gt;
You can see that the header starts out with Visibility=Collapsed, this way it won’t
take up any space and mess up the AccordionItem. 
&lt;br /&gt;
When the item expands, that visibility is toggled and a rendertransform is used to
bring it into view. 
&lt;/p&gt;
&lt;p&gt;
Let’s finish it off with some images, to make our accordion look nice! I grabbed some
images and created a somewhat better header:
&lt;/p&gt;
&lt;pre class="brush: xml; gutter: false;"&gt;  &amp;lt;layoutToolkit:AccordionItem Style=&amp;quot;{StaticResource AccordionItemStyle1}&amp;quot; MouseEnter=&amp;quot;item_MouseEnter&amp;quot;&amp;gt;
  &amp;lt;layoutToolkit:AccordionItem.Header&amp;gt;
    &amp;lt;Border Background=&amp;quot;#aa000000&amp;quot; Width=&amp;quot;400&amp;quot; Height=&amp;quot;80&amp;quot;&amp;gt;
      &amp;lt;StackPanel Margin=&amp;quot;10&amp;quot;&amp;gt;
        &amp;lt;TextBlock FontFamily=&amp;quot;Verdana&amp;quot; FontSize=&amp;quot;20&amp;quot; Foreground=&amp;quot;White&amp;quot;&amp;gt;Seamonster&amp;lt;/TextBlock&amp;gt; 
        &amp;lt;TextBlock FontFamily=&amp;quot;Verdana&amp;quot; FontSize=&amp;quot;12&amp;quot; Foreground=&amp;quot;White&amp;quot;&amp;gt;by Proudlove&amp;lt;/TextBlock&amp;gt; 
      &amp;lt;/StackPanel&amp;gt;
    &amp;lt;/Border&amp;gt;
  &amp;lt;/layoutToolkit:AccordionItem.Header&amp;gt;
  &amp;lt;Image Source=&amp;quot;/Images/3410783929_051d93bc86.jpg&amp;quot;  /&amp;gt;
&amp;lt;/layoutToolkit:AccordionItem&amp;gt;&lt;/pre&gt;
&lt;p&gt;
I also changed the animations slightly, to be somewhat slower. The result looks like
this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_16.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_7.png" width="661" height="284" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_18.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/AccordionPart4templatingexample_1219A/image_thumb_8.png" width="658" height="278" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I hope this little walkthrough helped.
&lt;/p&gt;
&lt;p&gt;
See the live sample &lt;a href="http://www.sitechno.com/Silverlight/AccordionHorizontalImages/AccordionHorizontalImages.html" target="_blank"&gt;here&lt;/a&gt;,
and download the project &lt;a href="http://www.sitechno.com/Silverlight/AccordionHorizontalImages/AccordionHorizontalImages.zip" target="_blank"&gt;here&lt;/a&gt;. 
&lt;br /&gt;
Let me know what you think!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=cba88585-5aff-4cc8-b00a-9e38c440df49" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,cba88585-5aff-4cc8-b00a-9e38c440df49.aspx</comments>
      <category>Silverlight;Silverlight Toolkit</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=d1f58a9f-67ab-4527-a353-28d33090b74e</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,d1f58a9f-67ab-4527-a353-28d33090b74e.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,d1f58a9f-67ab-4527-a353-28d33090b74e.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d1f58a9f-67ab-4527-a353-28d33090b74e</wfw:commentRss>
      <slash:comments>18</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The company where I work uses discussion lists quite religiously, and I’m sure other
companies do as well. A discussion list or group allows you to subscribe to emails
about a particular subject, for instance ‘silverlight’. People can send email to the
group and everyone that has subscribed will receive it.
</p>
        <p>
The problem is that this can become chaotic pretty quickly. Of course, everyone will
setup a rule in Outlook to move incoming mail from a group to a particular folder,
but I’m interested in creating a workflow that will help me stay on top of all of
those emails, all the time. That is hard, mainly because you will keep getting email
from conversations that you do not care about. Some of these conversations take days
to come to a conclusion, making you manually wade through all of that over and over
again.
</p>
        <p>
There are many systems devised to deal with email stress and organizing your life
inside Outlook. One important system is GTD (Getting Things Done). I find that those
do not directly apply to email received from discussion lists.
</p>
        <p>
What is needed, is some way to kill a thread and not be bothered with it again. There
are programs that will allow you to do that and I’ve played around with all of them. 
<br />
However, none quite suited me, maybe because I don’t trust programs to delete email.
There is one that is called ThreadKiller, which did not install for me. I believe
it does the same as I’m describing here.
</p>
        <p>
I am interested in the following workflow:
</p>
        <ol>
          <li>
email comes, either new threads or replies to old threads 
</li>
          <li>
I will look at the new threads and decide if I’m interested in them or not 
</li>
          <li>
Threads that I no longer want, should be moved to a folder 
</li>
          <li>
When I have time to actually read whole conversations, of the threads that remain,
I will first make sure that new replies to threads are removed 
</li>
        </ol>
        <p>
Basically it boils down to finding some way to easily find and delete mail that belongs
to threads I don’t want any more. Easier said than done! I ended up having to drop
to VB macros, which I really wanted to avoid. 
</p>
        <p>
Here is a description of my current setup.
</p>
        <h5>Step 1: searchfolder to manage new threads
</h5>
        <p>
Each discussion list I am on will have a searchfolder that only shows me ‘new’ mail.
You can create one by adding a search folder, and using the ‘advanced’ tab to setup
these two criteria:
</p>
        <p>
1. In Folder is (exactly) –the name of the folder that has the mail from the group
- 
<br />
2. Subject doesn’t contain RE:
</p>
        <h5>Step 2: setup a delete staging folder
</h5>
        <p>
Create a folder called Delete staging. It will contain the start of threads that you
are no longer interested in. Basically I will have a macro later on, that will look
in this folder and remove all the mail that belong to the same subject.
</p>
        <h5>Step 3: easily move new threads to the delete staging folder
</h5>
        <p>
I’m a keyboard junkie, and I want to easily move emails to that folder. 
<br />
I dropped into the VB Macro editor and used this code:
</p>
        <pre class="brush: vb; ruler: true; auto-links: false;">Sub MoveToDeleteStaging()
    Dim objItem As Outlook.MailItem
    Set objItem = Application.ActiveExplorer.Selection.Item(1)
        Dim objNamespace As NameSpace
    Dim objInboxFolder As Outlook.MAPIFolder
        Set objNamespace = Application.GetNamespace("MAPI")
    Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
    Set deleteFolder = objInboxFolder.Folders("Delete staging")
    
    objItem.Move (deleteFolder)
End Sub</pre>
        <p>
Even though I despise VB, this code is quite simple indeed. You can see that I hard
coded the folder “Delete staging” in there.
</p>
        <p>
Now, customize the toolbar to add this macro there. Rename it to something like ‘&amp;Delete
Thread’, using the ampersand to indicate the shortcut key.
</p>
        <p>
When you select a mail item and you execute the macro, it will move the item to the
delete staging folder.
</p>
        <h5>Step 4: scrub your folder
</h5>
        <p>
The real work is to make sure that mail you receive gets deleted. The best way might
be to create a rule to do that as the mail comes in. I don’t like that, because I
get a kick out of seeing how much mail was removed. So for now I use a manual process.
The code can be easily adjusted to run as a rule when new mail arrives.
</p>
        <p>
So, being a VB newbie, I’ve written code that is vey inefficient but luckily very
useful. The macro below will iterate through all the items in the delete staging folder
and remove any mail it finds in the folder that you are scrubbing.
</p>
        <pre class="brush: vb; ruler: true; auto-links: false;">Sub DeleteMessagesThatAreInDeleteStagingFolder()
    Dim deleteFolder As Outlook.Folder
    Dim currentFolder As Outlook.Folder
    Dim runningItem As Outlook.MailItem
    Dim threadItems As Outlook.Items
    Dim itemToDelete As Outlook.MailItem
    Dim objNamespace As NameSpace
    Dim objInboxFolder As Outlook.MAPIFolder
    Dim Filter As String
        
    Set objNamespace = Application.GetNamespace("MAPI")
    Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
    Set deleteFolder = objInboxFolder.Folders("Delete staging")
        
    Set currentFolder = Application.ActiveExplorer.currentFolder
    
    For Each runningItem In deleteFolder.Items
        Filter = "@SQL=" &amp; Chr(34) &amp; _
            "urn:schemas:httpmail:thread-topic" &amp; _
            Chr(34) &amp; "= '" &amp; Replace(runningItem.ConversationTopic, "'", "''") &amp; "'"
        Set threadItems = currentFolder.Items.Restrict(Filter)
        For Each itemToDelete In threadItems
            itemToDelete.Delete
        Next
    Next
    
End Sub</pre>
        <p>
The code uses a filter in the dsal language (some sort of SQL wannabe language used
by Outlook) to filter the email in the folder so it can then delete it. 
</p>
        <p>
Again, I created a toolbar shortcut for it.
</p>
        <h5>Usage:
</h5>
        <p>
Just go to your search folder and quickly triage all the mail that is there by either
reading the mail or moving it to the delete staging folder. Then go to the actual
folder and scrub it using the second macro. This will remove all the threads that
you were not interested in, leaving you with threads to you do want to read!!
</p>
        <p>
I hope that is useful to someone.
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=d1f58a9f-67ab-4527-a353-28d33090b74e" />
      </body>
      <title>Surviving email-overload from discussion lists in Outlook</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,d1f58a9f-67ab-4527-a353-28d33090b74e.aspx</guid>
      <link>http://www.sitechno.com/Blog/SurvivingEmailoverloadFromDiscussionListsInOutlook.aspx</link>
      <pubDate>Sat, 04 Apr 2009 23:45:09 GMT</pubDate>
      <description>&lt;p&gt;
The company where I work uses discussion lists quite religiously, and I’m sure other
companies do as well. A discussion list or group allows you to subscribe to emails
about a particular subject, for instance ‘silverlight’. People can send email to the
group and everyone that has subscribed will receive it.
&lt;/p&gt;
&lt;p&gt;
The problem is that this can become chaotic pretty quickly. Of course, everyone will
setup a rule in Outlook to move incoming mail from a group to a particular folder,
but I’m interested in creating a workflow that will help me stay on top of all of
those emails, all the time. That is hard, mainly because you will keep getting email
from conversations that you do not care about. Some of these conversations take days
to come to a conclusion, making you manually wade through all of that over and over
again.
&lt;/p&gt;
&lt;p&gt;
There are many systems devised to deal with email stress and organizing your life
inside Outlook. One important system is GTD (Getting Things Done). I find that those
do not directly apply to email received from discussion lists.
&lt;/p&gt;
&lt;p&gt;
What is needed, is some way to kill a thread and not be bothered with it again. There
are programs that will allow you to do that and I’ve played around with all of them. 
&lt;br /&gt;
However, none quite suited me, maybe because I don’t trust programs to delete email.
There is one that is called ThreadKiller, which did not install for me. I believe
it does the same as I’m describing here.
&lt;/p&gt;
&lt;p&gt;
I am interested in the following workflow:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
email comes, either new threads or replies to old threads 
&lt;/li&gt;
&lt;li&gt;
I will look at the new threads and decide if I’m interested in them or not 
&lt;/li&gt;
&lt;li&gt;
Threads that I no longer want, should be moved to a folder 
&lt;/li&gt;
&lt;li&gt;
When I have time to actually read whole conversations, of the threads that remain,
I will first make sure that new replies to threads are removed 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Basically it boils down to finding some way to easily find and delete mail that belongs
to threads I don’t want any more. Easier said than done! I ended up having to drop
to VB macros, which I really wanted to avoid. 
&lt;/p&gt;
&lt;p&gt;
Here is a description of my current setup.
&lt;/p&gt;
&lt;h5&gt;Step 1: searchfolder to manage new threads
&lt;/h5&gt;
&lt;p&gt;
Each discussion list I am on will have a searchfolder that only shows me ‘new’ mail.
You can create one by adding a search folder, and using the ‘advanced’ tab to setup
these two criteria:
&lt;/p&gt;
&lt;p&gt;
1. In Folder is (exactly) –the name of the folder that has the mail from the group
- 
&lt;br /&gt;
2. Subject doesn’t contain RE:
&lt;/p&gt;
&lt;h5&gt;Step 2: setup a delete staging folder
&lt;/h5&gt;
&lt;p&gt;
Create a folder called Delete staging. It will contain the start of threads that you
are no longer interested in. Basically I will have a macro later on, that will look
in this folder and remove all the mail that belong to the same subject.
&lt;/p&gt;
&lt;h5&gt;Step 3: easily move new threads to the delete staging folder
&lt;/h5&gt;
&lt;p&gt;
I’m a keyboard junkie, and I want to easily move emails to that folder. 
&lt;br /&gt;
I dropped into the VB Macro editor and used this code:
&lt;/p&gt;
&lt;pre class="brush: vb; ruler: true; auto-links: false;"&gt;Sub MoveToDeleteStaging()
    Dim objItem As Outlook.MailItem
    Set objItem = Application.ActiveExplorer.Selection.Item(1)
        Dim objNamespace As NameSpace
    Dim objInboxFolder As Outlook.MAPIFolder
        Set objNamespace = Application.GetNamespace(&amp;quot;MAPI&amp;quot;)
    Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
    Set deleteFolder = objInboxFolder.Folders(&amp;quot;Delete staging&amp;quot;)
    
    objItem.Move (deleteFolder)
End Sub&lt;/pre&gt;
&lt;p&gt;
Even though I despise VB, this code is quite simple indeed. You can see that I hard
coded the folder “Delete staging” in there.
&lt;/p&gt;
&lt;p&gt;
Now, customize the toolbar to add this macro there. Rename it to something like ‘&amp;amp;Delete
Thread’, using the ampersand to indicate the shortcut key.
&lt;/p&gt;
&lt;p&gt;
When you select a mail item and you execute the macro, it will move the item to the
delete staging folder.
&lt;/p&gt;
&lt;h5&gt;Step 4: scrub your folder
&lt;/h5&gt;
&lt;p&gt;
The real work is to make sure that mail you receive gets deleted. The best way might
be to create a rule to do that as the mail comes in. I don’t like that, because I
get a kick out of seeing how much mail was removed. So for now I use a manual process.
The code can be easily adjusted to run as a rule when new mail arrives.
&lt;/p&gt;
&lt;p&gt;
So, being a VB newbie, I’ve written code that is vey inefficient but luckily very
useful. The macro below will iterate through all the items in the delete staging folder
and remove any mail it finds in the folder that you are scrubbing.
&lt;/p&gt;
&lt;pre class="brush: vb; ruler: true; auto-links: false;"&gt;Sub DeleteMessagesThatAreInDeleteStagingFolder()
    Dim deleteFolder As Outlook.Folder
    Dim currentFolder As Outlook.Folder
    Dim runningItem As Outlook.MailItem
    Dim threadItems As Outlook.Items
    Dim itemToDelete As Outlook.MailItem
    Dim objNamespace As NameSpace
    Dim objInboxFolder As Outlook.MAPIFolder
    Dim Filter As String
        
    Set objNamespace = Application.GetNamespace(&amp;quot;MAPI&amp;quot;)
    Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
    Set deleteFolder = objInboxFolder.Folders(&amp;quot;Delete staging&amp;quot;)
        
    Set currentFolder = Application.ActiveExplorer.currentFolder
    
    For Each runningItem In deleteFolder.Items
        Filter = &amp;quot;@SQL=&amp;quot; &amp;amp; Chr(34) &amp;amp; _
            &amp;quot;urn:schemas:httpmail:thread-topic&amp;quot; &amp;amp; _
            Chr(34) &amp;amp; &amp;quot;= '&amp;quot; &amp;amp; Replace(runningItem.ConversationTopic, &amp;quot;'&amp;quot;, &amp;quot;''&amp;quot;) &amp;amp; &amp;quot;'&amp;quot;
        Set threadItems = currentFolder.Items.Restrict(Filter)
        For Each itemToDelete In threadItems
            itemToDelete.Delete
        Next
    Next
    
End Sub&lt;/pre&gt;
&lt;p&gt;
The code uses a filter in the dsal language (some sort of SQL wannabe language used
by Outlook) to filter the email in the folder so it can then delete it. 
&lt;/p&gt;
&lt;p&gt;
Again, I created a toolbar shortcut for it.
&lt;/p&gt;
&lt;h5&gt;Usage:
&lt;/h5&gt;
&lt;p&gt;
Just go to your search folder and quickly triage all the mail that is there by either
reading the mail or moving it to the delete staging folder. Then go to the actual
folder and scrub it using the second macro. This will remove all the threads that
you were not interested in, leaving you with threads to you do want to read!!
&lt;/p&gt;
&lt;p&gt;
I hope that is useful to someone.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=d1f58a9f-67ab-4527-a353-28d33090b74e" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,d1f58a9f-67ab-4527-a353-28d33090b74e.aspx</comments>
      <category>Personal;Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=bc06d8db-9ff2-427b-a122-dd1cd406ab1f</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,bc06d8db-9ff2-427b-a122-dd1cd406ab1f.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,bc06d8db-9ff2-427b-a122-dd1cd406ab1f.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=bc06d8db-9ff2-427b-a122-dd1cd406ab1f</wfw:commentRss>
      <slash:comments>63</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We continue our exploration of Accordion. This time we’ll take a look at some of the
template parts, namely ExpandableContentControl. See <a href="http://www.sitechno.com/Blog/AccordionPart1.aspx" target="_blank">part
1</a> and <a href="http://www.sitechno.com/Blog/AccordionPart2.aspx" target="_blank">part
2</a> if you didn’t yet.
</p>
        <h3>ExpandableContentControl
</h3>
        <p>
This control is part of AccordionItem and is used to display the content of an accordionItem.
It sits in the Primitives namespace, which means it will be used primarily as a part
of a template. It solves an important problem: being able to resize (expand/contract)
a piece of content, without triggering resize actions on the content itself. With
that I mean: if your AccordionItem would use a Grid or a DockPanel as it’s content
and I would just be animating the width or the height, you would see the panel changing
as it tries to keep up with the new sizes. Ofcourse, that would not be the case if
you had set an explicit width or height to the panel, but AccordionItem does not force
you to do so.So, during the resize of our AccordionItem, I don’t want the content
to have to resize. 
</p>
        <p>
Furthermore, it would be nice to make it really easy for you to determine how the
animation should look like. Do you want a gradual easein/out, a bump or something
different altogether? I want to be able to design my animation in Blend, using the
nifty keyspline features!
</p>
        <p>
I accomplish the above goals by throwing in a ScrollViewer and defining a DependencyProperty:
Percentage. 
</p>
        <p>
ScrollViewer allows Accordion to just determine the size the item will eventually
be (after expand action) and set it only once. At that moment the content of the scrollviewer
is going to resize itself accordingly. Then, as we animate the width or height of
the scrollviewer, its content is none-the-wiser. Hence, no ugly resize actions going
on.
</p>
        <p>
Making the actual animation be easily defined inside of Blend, is done by the above-mentioned
Percentage DP. 
<br />
Accordion only determines the size the AccordionItem will eventually be, I call it
the TargetSize. ExpandableContentControl will calculate and set its actual size using
to the following simple function: actualsize = percentage * TargetSize.
</p>
        <p>
Accordion also triggers a visualstate called either Expanded or Contracted on AccordionItem.
Those animate the percentage property on ExpandableContentControl. See this Xaml in
the template of AccordionItem:
</p>
        <div style="font-family: courier new; background: #141414; color: #bebec8; font-size: 10pt">
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   62</span> <span style="color: #d7d7d7">&lt;</span><span style="color: #cda869">vsm:VisualState</span><span style="color: #d7d7d7"></span><span style="color: #7386a5">x:Name</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"Collapsed"</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   63</span> <span style="color: #d7d7d7">   
&lt;</span><span style="color: #cda869">Storyboard</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   64</span> <span style="color: #d7d7d7">       
&lt;</span><span style="color: #cda869">DoubleAnimationUsingKeyFrames</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   65</span> <span style="color: #d7d7d7">            </span><span style="color: #7386a5">BeginTime</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"00:00:00"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   66</span> <span style="color: #d7d7d7">            </span><span style="color: #7386a5">Storyboard.TargetName</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"ExpandSite"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   67</span> <span style="color: #d7d7d7">            </span><span style="color: #7386a5">Storyboard.TargetProperty</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"(ExpandableContentControl.Percentage)"</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   68</span> <span style="color: #d7d7d7">           
&lt;</span><span style="color: #cda869">SplineDoubleKeyFrame</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   69</span> <span style="color: #d7d7d7">                </span><span style="color: #7386a5">KeyTime</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"00:00:00.3"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   70</span> <span style="color: #d7d7d7">                </span><span style="color: #7386a5">KeySpline</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"0.2,0,0,1"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   71</span> <span style="color: #d7d7d7">                </span><span style="color: #7386a5">Value</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"0"</span><span style="color: #d7d7d7"> /&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   72</span> <span style="color: #d7d7d7">       
&lt;/</span><span style="color: #cda869">DoubleAnimationUsingKeyFrames</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   73</span> <span style="color: #d7d7d7">   
&lt;/</span><span style="color: #cda869">Storyboard</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   74</span> <span style="color: #d7d7d7">&lt;/</span><span style="color: #cda869">vsm:VisualState</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   75</span> <span style="color: #d7d7d7">&lt;</span><span style="color: #cda869">vsm:VisualState</span><span style="color: #d7d7d7"></span><span style="color: #7386a5">x:Name</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"Expanded"</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   76</span> <span style="color: #d7d7d7">   
&lt;</span><span style="color: #cda869">Storyboard</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   77</span> <span style="color: #d7d7d7">       
&lt;</span><span style="color: #cda869">DoubleAnimationUsingKeyFrames</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   78</span> <span style="color: #d7d7d7">            </span><span style="color: #7386a5">BeginTime</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"00:00:00"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   79</span> <span style="color: #d7d7d7">            </span><span style="color: #7386a5">Storyboard.TargetName</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"ExpandSite"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   80</span> <span style="color: #d7d7d7">            </span><span style="color: #7386a5">Storyboard.TargetProperty</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"(ExpandableContentControl.Percentage)"</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   81</span> <span style="color: #d7d7d7">           
&lt;</span><span style="color: #cda869">SplineDoubleKeyFrame</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   82</span> <span style="color: #d7d7d7">                </span><span style="color: #7386a5">KeyTime</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"00:00:00.3"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   83</span> <span style="color: #d7d7d7">                </span><span style="color: #7386a5">KeySpline</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"0.2,0,0,1"</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   84</span> <span style="color: #d7d7d7">                </span><span style="color: #7386a5">Value</span><span style="color: #d7d7d7">=</span><span style="color: #8f9d6a">"1"</span><span style="color: #d7d7d7"> /&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   85</span> <span style="color: #d7d7d7">       
&lt;/</span><span style="color: #cda869">DoubleAnimationUsingKeyFrames</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   86</span> <span style="color: #d7d7d7">   
&lt;/</span><span style="color: #cda869">Storyboard</span><span style="color: #d7d7d7">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #a6a6ae">   87</span> <span style="color: #d7d7d7">&lt;/</span><span style="color: #cda869">vsm:VisualState</span><span style="color: #d7d7d7">&gt;</span></p>
        </div>
        <p>
This makes it possible to design your animation at the correct level (AccordionItem)
and makes it a very design friendly experience, because Blend allows you to edit keysplines
as follows:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart3_EF5A/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart3_EF5A/image_thumb.png" width="294" height="343" />
          </a>
        </p>
        <p>
(SL3 is adding a nice collection of other spline types that makes elastic AccordionItems
even easier!)
</p>
        <p>
I’ll discuss the remaining points of interest.
</p>
        <h5>RevealMode
</h5>
        <p>
Since I expose one property (Percentage) for you to animate, the control needs to
know whether that responds to the vertical or horizontal direction. Thus, AccordionItem
will set the correct RevealMode, corresponding to its own ExpandDirection.
</p>
        <h5>TargetSize
</h5>
        <p>
Already mentioned, setting the TargetSize will set the size of the ScrollViewer. It
will also recalculate the percentage. Let’s say I have an item that has a height of
100. Now another item is collapsed, so the Accordion decides the remaining items should
have a height of 160. The percentage that was once at 1 is recalculated to be 0.625. 
<br />
This way we don’t have to restart the full animation, but we can just resize nicely.
</p>
        <p>
          <br />
I hope that helps understanding this vital piece of the template. In the future, I
will either remove it (if the outlined problems can be solved more gracefully in another
way) or expose the style of ExpandableContentControl in AccordionItem, so it can be
more easily styled.
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=bc06d8db-9ff2-427b-a122-dd1cd406ab1f" />
      </body>
      <title>Accordion part 3</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,bc06d8db-9ff2-427b-a122-dd1cd406ab1f.aspx</guid>
      <link>http://www.sitechno.com/Blog/AccordionPart3.aspx</link>
      <pubDate>Sun, 29 Mar 2009 00:01:18 GMT</pubDate>
      <description>&lt;p&gt;
We continue our exploration of Accordion. This time we’ll take a look at some of the
template parts, namely ExpandableContentControl. See &lt;a href="http://www.sitechno.com/Blog/AccordionPart1.aspx" target="_blank"&gt;part
1&lt;/a&gt; and &lt;a href="http://www.sitechno.com/Blog/AccordionPart2.aspx" target="_blank"&gt;part
2&lt;/a&gt; if you didn’t yet.
&lt;/p&gt;
&lt;h3&gt;ExpandableContentControl
&lt;/h3&gt;
&lt;p&gt;
This control is part of AccordionItem and is used to display the content of an accordionItem.
It sits in the Primitives namespace, which means it will be used primarily as a part
of a template. It solves an important problem: being able to resize (expand/contract)
a piece of content, without triggering resize actions on the content itself. With
that I mean: if your AccordionItem would use a Grid or a DockPanel as it’s content
and I would just be animating the width or the height, you would see the panel changing
as it tries to keep up with the new sizes. Ofcourse, that would not be the case if
you had set an explicit width or height to the panel, but AccordionItem does not force
you to do so.So, during the resize of our AccordionItem, I don’t want the content
to have to resize. 
&lt;/p&gt;
&lt;p&gt;
Furthermore, it would be nice to make it really easy for you to determine how the
animation should look like. Do you want a gradual easein/out, a bump or something
different altogether? I want to be able to design my animation in Blend, using the
nifty keyspline features!
&lt;/p&gt;
&lt;p&gt;
I accomplish the above goals by throwing in a ScrollViewer and defining a DependencyProperty:
Percentage. 
&lt;/p&gt;
&lt;p&gt;
ScrollViewer allows Accordion to just determine the size the item will eventually
be (after expand action) and set it only once. At that moment the content of the scrollviewer
is going to resize itself accordingly. Then, as we animate the width or height of
the scrollviewer, its content is none-the-wiser. Hence, no ugly resize actions going
on.
&lt;/p&gt;
&lt;p&gt;
Making the actual animation be easily defined inside of Blend, is done by the above-mentioned
Percentage DP. 
&lt;br /&gt;
Accordion only determines the size the AccordionItem will eventually be, I call it
the TargetSize. ExpandableContentControl will calculate and set its actual size using
to the following simple function: actualsize = percentage * TargetSize.
&lt;/p&gt;
&lt;p&gt;
Accordion also triggers a visualstate called either Expanded or Contracted on AccordionItem.
Those animate the percentage property on ExpandableContentControl. See this Xaml in
the template of AccordionItem:
&lt;/p&gt;
&lt;div style="font-family: courier new; background: #141414; color: #bebec8; font-size: 10pt"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 62&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;vsm:VisualState&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;x:Name&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;Collapsed&amp;quot;&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 63&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 64&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 65&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;BeginTime&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;00:00:00&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 66&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;ExpandSite&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 67&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;(ExpandableContentControl.Percentage)&amp;quot;&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 68&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;SplineDoubleKeyFrame&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 69&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;KeyTime&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;00:00:00.3&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 70&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;KeySpline&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;0.2,0,0,1&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 71&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;Value&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 72&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #cda869"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 73&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #cda869"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 74&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #cda869"&gt;vsm:VisualState&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 75&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;vsm:VisualState&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;x:Name&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;Expanded&amp;quot;&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 76&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 77&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 78&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;BeginTime&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;00:00:00&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 79&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;ExpandSite&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 80&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;(ExpandableContentControl.Percentage)&amp;quot;&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 81&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;&lt;/span&gt;&lt;span style="color: #cda869"&gt;SplineDoubleKeyFrame&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 82&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;KeyTime&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;00:00:00.3&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 83&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;KeySpline&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;0.2,0,0,1&amp;quot;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 84&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #7386a5"&gt;Value&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;=&lt;/span&gt;&lt;span style="color: #8f9d6a"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 85&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #cda869"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 86&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;#160;&amp;#160;&amp;#160;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #cda869"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #a6a6ae"&gt;&amp;#160;&amp;#160; 87&lt;/span&gt;&amp;#160;&lt;span style="color: #d7d7d7"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #cda869"&gt;vsm:VisualState&lt;/span&gt;&lt;span style="color: #d7d7d7"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
This makes it possible to design your animation at the correct level (AccordionItem)
and makes it a very design friendly experience, because Blend allows you to edit keysplines
as follows:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart3_EF5A/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart3_EF5A/image_thumb.png" width="294" height="343" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
(SL3 is adding a nice collection of other spline types that makes elastic AccordionItems
even easier!)
&lt;/p&gt;
&lt;p&gt;
I’ll discuss the remaining points of interest.
&lt;/p&gt;
&lt;h5&gt;RevealMode
&lt;/h5&gt;
&lt;p&gt;
Since I expose one property (Percentage) for you to animate, the control needs to
know whether that responds to the vertical or horizontal direction. Thus, AccordionItem
will set the correct RevealMode, corresponding to its own ExpandDirection.
&lt;/p&gt;
&lt;h5&gt;TargetSize
&lt;/h5&gt;
&lt;p&gt;
Already mentioned, setting the TargetSize will set the size of the ScrollViewer. It
will also recalculate the percentage. Let’s say I have an item that has a height of
100. Now another item is collapsed, so the Accordion decides the remaining items should
have a height of 160. The percentage that was once at 1 is recalculated to be 0.625. 
&lt;br /&gt;
This way we don’t have to restart the full animation, but we can just resize nicely.
&lt;/p&gt;
&lt;p&gt;
&lt;br /&gt;
I hope that helps understanding this vital piece of the template. In the future, I
will either remove it (if the outlined problems can be solved more gracefully in another
way) or expose the style of ExpandableContentControl in AccordionItem, so it can be
more easily styled.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=bc06d8db-9ff2-427b-a122-dd1cd406ab1f" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,bc06d8db-9ff2-427b-a122-dd1cd406ab1f.aspx</comments>
      <category>Silverlight;Silverlight Toolkit</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=cbe50709-e1f6-4e67-a779-ca1cf4c747c3</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,cbe50709-e1f6-4e67-a779-ca1cf4c747c3.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,cbe50709-e1f6-4e67-a779-ca1cf4c747c3.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=cbe50709-e1f6-4e67-a779-ca1cf4c747c3</wfw:commentRss>
      <slash:comments>29</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Completely unrelated to anything on this site, I wanted to talk about IE8 for a minute.
It looks like a great browser, but on my home machine, just spinning up a tab took
about 3 seconds. When I noticed that other people did not have this problem, I started
to investigate. These are the two tips that I’ve found:
</p>
        <p>
The first is by <a href="http://blogs.zdnet.com/Bott/?p=754" target="_blank">Ed Bot</a> and
basically tells you to execute ‘regsvr32 actxprxy.dll’ from an elevated command prompt.
That registers a dll that in certain configurations is not registered. It can make
a huge difference.
</p>
        <p>
The second on is the the one that saved me. I don’t know the source, but there are
several blogs telling you to look at your restricted sites (Tools/InternetOptions/Security/Restricted
Sites, press the button labeled ‘sites’ ). 
<br />
I had used spybot long ago, which had added a huge list of sites there. Apparently
this can really slow down outlook and ie! 
<br />
Remove them by resetting your settings to default (Advanced tab, button labeled ‘reset’).
</p>
        <p>
Now I have a blindingly fast internet explorer, and I must admit, I do love this browser
now. Switching back!
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=cbe50709-e1f6-4e67-a779-ca1cf4c747c3" />
      </body>
      <title>Speed up IE8 tips</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,cbe50709-e1f6-4e67-a779-ca1cf4c747c3.aspx</guid>
      <link>http://www.sitechno.com/Blog/SpeedUpIE8Tips.aspx</link>
      <pubDate>Sat, 28 Mar 2009 22:08:28 GMT</pubDate>
      <description>&lt;p&gt;
Completely unrelated to anything on this site, I wanted to talk about IE8 for a minute.
It looks like a great browser, but on my home machine, just spinning up a tab took
about 3 seconds. When I noticed that other people did not have this problem, I started
to investigate. These are the two tips that I’ve found:
&lt;/p&gt;
&lt;p&gt;
The first is by &lt;a href="http://blogs.zdnet.com/Bott/?p=754" target="_blank"&gt;Ed Bot&lt;/a&gt; and
basically tells you to execute ‘regsvr32 actxprxy.dll’ from an elevated command prompt.
That registers a dll that in certain configurations is not registered. It can make
a huge difference.
&lt;/p&gt;
&lt;p&gt;
The second on is the the one that saved me. I don’t know the source, but there are
several blogs telling you to look at your restricted sites (Tools/InternetOptions/Security/Restricted
Sites, press the button labeled ‘sites’ ). 
&lt;br /&gt;
I had used spybot long ago, which had added a huge list of sites there. Apparently
this can really slow down outlook and ie! 
&lt;br /&gt;
Remove them by resetting your settings to default (Advanced tab, button labeled ‘reset’).
&lt;/p&gt;
&lt;p&gt;
Now I have a blindingly fast internet explorer, and I must admit, I do love this browser
now. Switching back!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=cbe50709-e1f6-4e67-a779-ca1cf4c747c3" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,cbe50709-e1f6-4e67-a779-ca1cf4c747c3.aspx</comments>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=bf191966-f893-421c-949a-16d8e0e36106</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,bf191966-f893-421c-949a-16d8e0e36106.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,bf191966-f893-421c-949a-16d8e0e36106.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=bf191966-f893-421c-949a-16d8e0e36106</wfw:commentRss>
      <slash:comments>33</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m glad to see accordion getting the excitement that it’s getting. I’ve gotten great
feedback, keep it coming!
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/AccordionPart1.aspx" target="_blank">Part 1</a> was
concerned with Accordion itself, we will now focus on the individual parts of Accordion.
</p>
        <h4>AccordionItem
</h4>
        <p>
AccordionItem is to Accordion as is ListboxItem to Listbox. Accordion will only work
with AccordionItems, and that is why, if you feed Accordion an item that is not of
type AccordionItem, it will wrap it inside of one.
</p>
        <p>
AccordionItem has several important jobs:
</p>
        <ul>
          <li>
It needs to display a header and content.</li>
          <li>
It needs to be able to ‘open’ and ‘close’</li>
          <li>
It needs to be able to work in several ExpandDirections (Left, Right, Top, Bottom)</li>
        </ul>
        <p>
AccordionItem mimicks Expander in many ways (although I changed the template considerably)
but inherits from HeaderedContentControl. Therefore, it has two important properties
it gains from HeaderedContentControl: HeaderTemplate and ContentTemplate. 
<br />
These templates are used to allow you to customize the header and content.
</p>
        <p>
I will use KeyValue pairs to easily create a few AccordionItems:
</p>
        <div style="font-family: courier new">
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            acc.ItemsSource = <span style="color: blue">new</span>[]</pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                                  {</pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                                          <span style="color: blue">new</span> KeyValuePair&lt;<span style="color: blue">string</span>, <span style="color: blue">string</span>&gt;(<span style="color: maroon">"A
header"</span>, <span style="color: maroon">"And the content of the accordion
item"</span>),</pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                                          <span style="color: blue">new</span> KeyValuePair&lt;<span style="color: blue">string</span>, <span style="color: blue">string</span>&gt;(<span style="color: maroon">"Hello"</span>, <span style="color: maroon">"World"</span>)</pre>
                                  
};
</div>
        <p>
Let’s take a look at an Accordion and it’s Xaml:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart2_136C6/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart2_136C6/image_thumb.png" width="789" height="232" />
          </a>
        </p>
        <h5>ExpandDirection
</h5>
        <p>
An AccordionItem has the same ExpandDirection property as Accordion. When contained
within an Accordion, AccordionItem will get the correct ExpandDirection from Accordion
and will not allow you to change it individually.
</p>
        <p>
ExpandDirection may only be set by Accordion, to prevent from weird mixes of ExpandDirections.
Unfortunately, that does limit a few scenario’s (as in horizontal Accordion layout
with vertical AccordionItems). If this turns out to be a common featurerequest, I’ll
look into opening this up.
</p>
        <h5>Accordion.ItemContainerGenerator
</h5>
        <p>
Accordion exposes an ItemContainerGenerator which has very helpful methods, such as
‘ContainerFromItem’ and even ContainerFromIndex’. So it is really easy to go from
AccordionItem, to Item and vice versa. 
<br />
This code might make you happy:
</p>
        <div style="font-family: courier new">
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: blue">for</span> (<span style="color: blue">int</span> i
= <span style="color: maroon">0</span>; i &lt; acc.Items.Count; i++)</pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                AccordionItem item = acc.ItemContainerGenerator.ContainerFromIndex(i) <span style="color: blue">as</span> AccordionItem;</pre>
             }
</div>
        <h5>Locking mechanism
</h5>
        <p>
In certain SelectionModes, Accordion must make sure that at least one item is selected.
It does so by locking an item if it is the last one open. If you somehow force it
to close (through code), Accordion will just open the first AccordionItem in the list.
However, that is not that simple, since an AccordionItem may not be unselected, while
it is locked. 
</p>
        <p>
Since AccordionItem will actually throw an exception when it is unselected while locked,
I expose a boolean ‘IsLocked’ that you can use to make sure you don’t accidently do
this. 
<br />
I expose a VisualState that allows you to visualize the lock if you’d like.
</p>
        <p>
The best way to unselect the AccordionItem while in such a mode, is to select a different
item.
</p>
        <h5>ExpandableContentControl and AccordionButton
</h5>
        <p>
These are two template parts on the AccordionItem. The first takes care of opening
and closing in a nice fashion and the latter makes it easier to template the header.
It is not necessary, but adds a nice touch. I will talk more about templating them
in a follow up post. 
<br />
In the meantime, it is noteworthy that there is a property AccordionButtonStyle that
you can use to style the button more easily.
</p>
        <h5>Selected and Unselected events
</h5>
        <p>
Subscribe to these events to know when the user has selected an AccordionItem. Alternatively,
you can use the SelectionChanged event on Accordion.
</p>
        <h5>Layout
</h5>
        <p>
Under the covers, there is a lot of layout action going on! The item needs to know
how to open itself, and also needs to be told _when_ to do so. The actual opening
and closing does not correspond to the IsSelected state. In other words: IsSelected
will be set whenever an item is selected, which could mean the AccordionItem is still
closed. Accordion will instruct AccordionItem to actually open to visualize the new
IsSelected state.
</p>
        <h5>Templating
</h5>
        <p>
The most important part of the template is:
</p>
        <pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 1</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">Border</span>
            <span style="color: red">x:Name</span>="<span style="color: blue">Background</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 2</span>
            <span style="color: red">Padding</span>="<span style="color: blue">{TemplateBinding
Padding}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 3</span>
            <span style="color: red">BorderBrush</span>="<span style="color: blue">{TemplateBinding
BorderBrush}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 4</span>
            <span style="color: red">BorderThickness</span>="<span style="color: blue">{TemplateBinding
BorderThickness}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 5</span>
            <span style="color: red">CornerRadius</span>="<span style="color: blue">1,1,1,1</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 6</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">Grid</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 7</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">Grid.RowDefinitions</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 8</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">RowDefinition</span>
            <span style="color: red">Height</span>="<span style="color: blue">Auto</span>" <span style="color: red">x:Name</span>="<span style="color: blue">rd0</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 9</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">RowDefinition</span>
            <span style="color: red">Height</span>="<span style="color: blue">Auto</span>" <span style="color: red">x:Name</span>="<span style="color: blue">rd1</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 10</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">Grid.RowDefinitions</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 11</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">Grid.ColumnDefinitions</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 12</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ColumnDefinition</span>
            <span style="color: red">Width</span>="<span style="color: blue">Auto</span>" <span style="color: red">x:Name</span>="<span style="color: blue">cd0</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 13</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ColumnDefinition</span>
            <span style="color: red">Width</span>="<span style="color: blue">Auto</span>" <span style="color: red">x:Name</span>="<span style="color: blue">cd1</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 14</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">Grid.ColumnDefinitions</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 15</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 16</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutPrimitivesToolkit:AccordionButton</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 17</span>
            <span style="color: red">x:Name</span>="<span style="color: blue">ExpanderButton</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 18</span>
            <span style="color: red">Style</span>="<span style="color: blue">{TemplateBinding
AccordionButtonStyle}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 19</span>
            <span style="color: red">Content</span>="<span style="color: blue">{TemplateBinding
Header}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 20</span>
            <span style="color: red">ContentTemplate</span>="<span style="color: blue">{TemplateBinding
HeaderTemplate}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 21</span>
            <span style="color: red">IsChecked</span>="<span style="color: blue">{TemplateBinding
IsSelected}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 22</span>
            <span style="color: red">IsTabStop</span>="<span style="color: blue">True</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 23</span>
            <span style="color: red">Grid.Row</span>="<span style="color: blue">0</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 24</span>
            <span style="color: red">Padding</span>="<span style="color: blue">0,0,0,0</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 25</span>
            <span style="color: red">Margin</span>="<span style="color: blue">0,0,0,0</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 26</span>
            <span style="color: red">FontFamily</span>="<span style="color: blue">{TemplateBinding
FontFamily}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 27</span>
            <span style="color: red">FontSize</span>="<span style="color: blue">{TemplateBinding
FontSize}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 28</span>
            <span style="color: red">FontStretch</span>="<span style="color: blue">{TemplateBinding
FontStretch}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 29</span>
            <span style="color: red">FontStyle</span>="<span style="color: blue">{TemplateBinding
FontStyle}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 30</span>
            <span style="color: red">FontWeight</span>="<span style="color: blue">{TemplateBinding
FontWeight}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 31</span>
            <span style="color: red">Foreground</span>="<span style="color: blue">{TemplateBinding
Foreground}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 32</span>
            <span style="color: red">VerticalContentAlignment</span>="<span style="color: blue">{TemplateBinding
VerticalContentAlignment}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 33</span>
            <span style="color: red">HorizontalAlignment</span>="<span style="color: blue">Stretch</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 34</span>
            <span style="color: red">VerticalAlignment</span>="<span style="color: blue">Stretch</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 35</span>
            <span style="color: red">HorizontalContentAlignment</span>="<span style="color: blue">{TemplateBinding
HorizontalContentAlignment}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 36</span>
            <span style="color: red">Background</span>="<span style="color: blue">{TemplateBinding
Background}</span>" /<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 37</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 38</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutPrimitivesToolkit:ExpandableContentControl</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 39</span>
            <span style="color: red">x:Name</span>="<span style="color: blue">ExpandSite</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 40</span>
            <span style="color: red">Grid.Row</span>="<span style="color: blue">1</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 41</span>
            <span style="color: red">IsTabStop</span>="<span style="color: blue">False</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 42</span>
            <span style="color: red">Percentage</span>="<span style="color: blue">0</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 43</span>
            <span style="color: red">RevealMode</span>="<span style="color: blue">{TemplateBinding
ExpandDirection}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 44</span>
            <span style="color: red">Content</span>="<span style="color: blue">{TemplateBinding
Content}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 45</span>
            <span style="color: red">ContentTemplate</span>="<span style="color: blue">{TemplateBinding
ContentTemplate}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 46</span>
            <span style="color: red">Margin</span>="<span style="color: blue">0,0,0,0</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 47</span>
            <span style="color: red">FontFamily</span>="<span style="color: blue">{TemplateBinding
FontFamily}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 48</span>
            <span style="color: red">FontSize</span>="<span style="color: blue">{TemplateBinding
FontSize}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 49</span>
            <span style="color: red">FontStretch</span>="<span style="color: blue">{TemplateBinding
FontStretch}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 50</span>
            <span style="color: red">FontStyle</span>="<span style="color: blue">{TemplateBinding
FontStyle}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 51</span>
            <span style="color: red">FontWeight</span>="<span style="color: blue">{TemplateBinding
FontWeight}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 52</span>
            <span style="color: red">Foreground</span>="<span style="color: blue">{TemplateBinding
Foreground}</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 53</span>
            <span style="color: red">HorizontalContentAlignment</span>="<span style="color: blue">Left</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 54</span>
            <span style="color: red">VerticalContentAlignment</span>="<span style="color: blue">Top</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 55</span>
            <span style="color: red">HorizontalAlignment</span>="<span style="color: blue">Stretch</span>" </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 56</span>
            <span style="color: red">VerticalAlignment</span>="<span style="color: blue">Stretch</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 57</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">Grid</span><span style="color: blue">&gt;</span></pre>
          <span style="color: teal"> 58</span>
          <span style="color: blue">&lt;</span>/<span style="color: maroon">Border</span><span style="color: blue">&gt;</span></pre>
        <p>
Lines 7 through 14 create a grid with 2 columns and 2 rows. 
<br />
Line 16 shows the AccordionButton, which is the little arrow + header.The arrow always
points to the content and is in different locations, depending on the ExpandDirection. 
<br />
Line 38 is the ExpandableContentControl, which takes care of the content.
</p>
        <p>
An AccordionItem has, amongst others, 4 visual states for ExpandDirection. I will
show the ExpandLeft state:
</p>
        <pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 1</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">vsm:VisualState</span>
            <span style="color: red">x:Name</span>="<span style="color: blue">ExpandLeft</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 2</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">Storyboard</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 3</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">ExpanderButton</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">(Grid.ColumnSpan)</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 4</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">1</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 5</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 6</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">ExpandSite</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">(Grid.ColumnSpan)</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 7</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">1</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 8</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 9</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">ExpanderButton</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">(Grid.RowSpan)</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 10</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">2</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 11</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 12</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">ExpandSite</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">(Grid.RowSpan)</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 13</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">2</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 14</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 15</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 16</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">ExpanderButton</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">(Grid.Column)</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 17</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">1</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 18</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 19</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">ExpandSite</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">(Grid.Row)</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 20</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">0</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 21</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 22</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">rd0</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">Height</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 23</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">*</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 24</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 25</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">ObjectAnimationUsingKeyFrames</span>
            <span style="color: red">Duration</span>="<span style="color: blue">0</span>" <span style="color: red">Storyboard.TargetName</span>="<span style="color: blue">cd0</span>" <span style="color: red">Storyboard.TargetProperty</span>="<span style="color: blue">Width</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 26</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DiscreteObjectKeyFrame</span>
            <span style="color: red">KeyTime</span>="<span style="color: blue">0</span>" <span style="color: red">Value</span>="<span style="color: blue">*</span>"/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 27</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 28</span>
            <span style="color: blue">&lt;</span>/<span style="color: maroon">Storyboard</span><span style="color: blue">&gt;</span></pre>
          <span style="color: teal"> 29</span>
          <span style="color: blue">&lt;</span>/<span style="color: maroon">vsm:VisualState</span><span style="color: blue">&gt;</span></pre>
        <p>
Everything in there is actually repositioning the AccordionButton (header) and the
ExpandableContentControl (content) inside different grid cells. 
</p>
        <p>
In this case, you can imagine the header being in column 1 and the content taking
up column 2.
</p>
        <p>
You should not need to have to style an accordionItem itself that much. Most of the
template is just about positioning the Header versus the Content. The only reason
I see for restyling accordionItem is if you are unhappy with the defaults (easily
changed) or with the position of the header and content. All the other styling would
be done in either AccordionButton or ExpandableContentControl. Let me know if this
is not the case for your scenario.
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=bf191966-f893-421c-949a-16d8e0e36106" />
      </body>
      <title>Accordion, part 2</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,bf191966-f893-421c-949a-16d8e0e36106.aspx</guid>
      <link>http://www.sitechno.com/Blog/AccordionPart2.aspx</link>
      <pubDate>Thu, 26 Mar 2009 05:05:36 GMT</pubDate>
      <description>&lt;p&gt;
I’m glad to see accordion getting the excitement that it’s getting. I’ve gotten great
feedback, keep it coming!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/AccordionPart1.aspx" target="_blank"&gt;Part 1&lt;/a&gt; was
concerned with Accordion itself, we will now focus on the individual parts of Accordion.
&lt;/p&gt;
&lt;h4&gt;AccordionItem
&lt;/h4&gt;
&lt;p&gt;
AccordionItem is to Accordion as is ListboxItem to Listbox. Accordion will only work
with AccordionItems, and that is why, if you feed Accordion an item that is not of
type AccordionItem, it will wrap it inside of one.
&lt;/p&gt;
&lt;p&gt;
AccordionItem has several important jobs:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
It needs to display a header and content.&lt;/li&gt;
&lt;li&gt;
It needs to be able to ‘open’ and ‘close’&lt;/li&gt;
&lt;li&gt;
It needs to be able to work in several ExpandDirections (Left, Right, Top, Bottom)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
AccordionItem mimicks Expander in many ways (although I changed the template considerably)
but inherits from HeaderedContentControl. Therefore, it has two important properties
it gains from HeaderedContentControl: HeaderTemplate and ContentTemplate. 
&lt;br /&gt;
These templates are used to allow you to customize the header and content.
&lt;/p&gt;
&lt;p&gt;
I will use KeyValue pairs to easily create a few AccordionItems:
&lt;/p&gt;
&lt;div style="font-family: courier new"&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; acc.ItemsSource = &lt;span style="color: blue"&gt;new&lt;/span&gt;[]&lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;new&lt;/span&gt; KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color: maroon"&gt;&amp;quot;A
header&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;And the content of the accordion
item&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;new&lt;/span&gt; KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color: maroon"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;World&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
};
&lt;/div&gt;
&lt;p&gt;
Let’s take a look at an Accordion and it’s Xaml:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart2_136C6/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart2_136C6/image_thumb.png" width="789" height="232" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;h5&gt;ExpandDirection
&lt;/h5&gt;
&lt;p&gt;
An AccordionItem has the same ExpandDirection property as Accordion. When contained
within an Accordion, AccordionItem will get the correct ExpandDirection from Accordion
and will not allow you to change it individually.
&lt;/p&gt;
&lt;p&gt;
ExpandDirection may only be set by Accordion, to prevent from weird mixes of ExpandDirections.
Unfortunately, that does limit a few scenario’s (as in horizontal Accordion layout
with vertical AccordionItems). If this turns out to be a common featurerequest, I’ll
look into opening this up.
&lt;/p&gt;
&lt;h5&gt;Accordion.ItemContainerGenerator
&lt;/h5&gt;
&lt;p&gt;
Accordion exposes an ItemContainerGenerator which has very helpful methods, such as
‘ContainerFromItem’ and even ContainerFromIndex’. So it is really easy to go from
AccordionItem, to Item and vice versa. 
&lt;br /&gt;
This code might make you happy:
&lt;/p&gt;
&lt;div style="font-family: courier new"&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;for&lt;/span&gt; (&lt;span style="color: blue"&gt;int&lt;/span&gt; i
= &lt;span style="color: maroon"&gt;0&lt;/span&gt;; i &amp;lt; acc.Items.Count; i++)&lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AccordionItem item = acc.ItemContainerGenerator.ContainerFromIndex(i) &lt;span style="color: blue"&gt;as&lt;/span&gt; AccordionItem;&lt;/pre&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }
&lt;/div&gt;
&lt;h5&gt;Locking mechanism
&lt;/h5&gt;
&lt;p&gt;
In certain SelectionModes, Accordion must make sure that at least one item is selected.
It does so by locking an item if it is the last one open. If you somehow force it
to close (through code), Accordion will just open the first AccordionItem in the list.
However, that is not that simple, since an AccordionItem may not be unselected, while
it is locked. 
&lt;/p&gt;
&lt;p&gt;
Since AccordionItem will actually throw an exception when it is unselected while locked,
I expose a boolean ‘IsLocked’ that you can use to make sure you don’t accidently do
this. 
&lt;br /&gt;
I expose a VisualState that allows you to visualize the lock if you’d like.
&lt;/p&gt;
&lt;p&gt;
The best way to unselect the AccordionItem while in such a mode, is to select a different
item.
&lt;/p&gt;
&lt;h5&gt;ExpandableContentControl and AccordionButton
&lt;/h5&gt;
&lt;p&gt;
These are two template parts on the AccordionItem. The first takes care of opening
and closing in a nice fashion and the latter makes it easier to template the header.
It is not necessary, but adds a nice touch. I will talk more about templating them
in a follow up post. 
&lt;br /&gt;
In the meantime, it is noteworthy that there is a property AccordionButtonStyle that
you can use to style the button more easily.
&lt;/p&gt;
&lt;h5&gt;Selected and Unselected events
&lt;/h5&gt;
&lt;p&gt;
Subscribe to these events to know when the user has selected an AccordionItem. Alternatively,
you can use the SelectionChanged event on Accordion.
&lt;/p&gt;
&lt;h5&gt;Layout
&lt;/h5&gt;
&lt;p&gt;
Under the covers, there is a lot of layout action going on! The item needs to know
how to open itself, and also needs to be told _when_ to do so. The actual opening
and closing does not correspond to the IsSelected state. In other words: IsSelected
will be set whenever an item is selected, which could mean the AccordionItem is still
closed. Accordion will instruct AccordionItem to actually open to visualize the new
IsSelected state.
&lt;/p&gt;
&lt;h5&gt;Templating
&lt;/h5&gt;
&lt;p&gt;
The most important part of the template is:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 1&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;Border&lt;/span&gt; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Background&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 2&lt;/span&gt; &lt;span style="color: red"&gt;Padding&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
Padding}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 3&lt;/span&gt; &lt;span style="color: red"&gt;BorderBrush&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
BorderBrush}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 4&lt;/span&gt; &lt;span style="color: red"&gt;BorderThickness&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
BorderThickness}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 5&lt;/span&gt; &lt;span style="color: red"&gt;CornerRadius&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;1,1,1,1&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 6&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 7&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 8&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;RowDefinition&lt;/span&gt; &lt;span style="color: red"&gt;Height&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Auto&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;rd0&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 9&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;RowDefinition&lt;/span&gt; &lt;span style="color: red"&gt;Height&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Auto&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;rd1&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 10&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 11&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 12&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ColumnDefinition&lt;/span&gt; &lt;span style="color: red"&gt;Width&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Auto&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;cd0&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 13&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ColumnDefinition&lt;/span&gt; &lt;span style="color: red"&gt;Width&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Auto&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;cd1&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 14&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 15&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 16&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutPrimitivesToolkit:AccordionButton&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 17&lt;/span&gt; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpanderButton&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 18&lt;/span&gt; &lt;span style="color: red"&gt;Style&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
AccordionButtonStyle}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 19&lt;/span&gt; &lt;span style="color: red"&gt;Content&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
Header}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 20&lt;/span&gt; &lt;span style="color: red"&gt;ContentTemplate&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
HeaderTemplate}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 21&lt;/span&gt; &lt;span style="color: red"&gt;IsChecked&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
IsSelected}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 22&lt;/span&gt; &lt;span style="color: red"&gt;IsTabStop&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;True&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 23&lt;/span&gt; &lt;span style="color: red"&gt;Grid.Row&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 24&lt;/span&gt; &lt;span style="color: red"&gt;Padding&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0,0,0,0&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 25&lt;/span&gt; &lt;span style="color: red"&gt;Margin&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0,0,0,0&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 26&lt;/span&gt; &lt;span style="color: red"&gt;FontFamily&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontFamily}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 27&lt;/span&gt; &lt;span style="color: red"&gt;FontSize&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontSize}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 28&lt;/span&gt; &lt;span style="color: red"&gt;FontStretch&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontStretch}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 29&lt;/span&gt; &lt;span style="color: red"&gt;FontStyle&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontStyle}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 30&lt;/span&gt; &lt;span style="color: red"&gt;FontWeight&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontWeight}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 31&lt;/span&gt; &lt;span style="color: red"&gt;Foreground&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
Foreground}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 32&lt;/span&gt; &lt;span style="color: red"&gt;VerticalContentAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
VerticalContentAlignment}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 33&lt;/span&gt; &lt;span style="color: red"&gt;HorizontalAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Stretch&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 34&lt;/span&gt; &lt;span style="color: red"&gt;VerticalAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Stretch&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 35&lt;/span&gt; &lt;span style="color: red"&gt;HorizontalContentAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
HorizontalContentAlignment}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 36&lt;/span&gt; &lt;span style="color: red"&gt;Background&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
Background}&lt;/span&gt;&amp;quot; /&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 37&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 38&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutPrimitivesToolkit:ExpandableContentControl&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 39&lt;/span&gt; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpandSite&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 40&lt;/span&gt; &lt;span style="color: red"&gt;Grid.Row&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;1&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 41&lt;/span&gt; &lt;span style="color: red"&gt;IsTabStop&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;False&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 42&lt;/span&gt; &lt;span style="color: red"&gt;Percentage&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 43&lt;/span&gt; &lt;span style="color: red"&gt;RevealMode&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
ExpandDirection}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 44&lt;/span&gt; &lt;span style="color: red"&gt;Content&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
Content}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 45&lt;/span&gt; &lt;span style="color: red"&gt;ContentTemplate&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
ContentTemplate}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 46&lt;/span&gt; &lt;span style="color: red"&gt;Margin&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0,0,0,0&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 47&lt;/span&gt; &lt;span style="color: red"&gt;FontFamily&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontFamily}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 48&lt;/span&gt; &lt;span style="color: red"&gt;FontSize&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontSize}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 49&lt;/span&gt; &lt;span style="color: red"&gt;FontStretch&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontStretch}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 50&lt;/span&gt; &lt;span style="color: red"&gt;FontStyle&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontStyle}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 51&lt;/span&gt; &lt;span style="color: red"&gt;FontWeight&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
FontWeight}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 52&lt;/span&gt; &lt;span style="color: red"&gt;Foreground&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{TemplateBinding
Foreground}&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 53&lt;/span&gt; &lt;span style="color: red"&gt;HorizontalContentAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Left&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 54&lt;/span&gt; &lt;span style="color: red"&gt;VerticalContentAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Top&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 55&lt;/span&gt; &lt;span style="color: red"&gt;HorizontalAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Stretch&lt;/span&gt;&amp;quot; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 56&lt;/span&gt; &lt;span style="color: red"&gt;VerticalAlignment&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Stretch&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 57&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;span style="color: teal"&gt; 58&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;Border&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Lines 7 through 14 create a grid with 2 columns and 2 rows. 
&lt;br /&gt;
Line 16 shows the AccordionButton, which is the little arrow + header.The arrow always
points to the content and is in different locations, depending on the ExpandDirection. 
&lt;br /&gt;
Line 38 is the ExpandableContentControl, which takes care of the content.
&lt;/p&gt;
&lt;p&gt;
An AccordionItem has, amongst others, 4 visual states for ExpandDirection. I will
show the ExpandLeft state:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 1&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;vsm:VisualState&lt;/span&gt; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpandLeft&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 2&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;Storyboard&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 3&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpanderButton&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;(Grid.ColumnSpan)&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 4&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;1&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 5&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 6&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpandSite&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;(Grid.ColumnSpan)&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 7&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;1&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 8&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 9&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpanderButton&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;(Grid.RowSpan)&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 10&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;2&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 11&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 12&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpandSite&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;(Grid.RowSpan)&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 13&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;2&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 14&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 15&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 16&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpanderButton&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;(Grid.Column)&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 17&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;1&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 18&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 19&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ExpandSite&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;(Grid.Row)&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 20&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 21&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 22&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;rd0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Height&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 23&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;*&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 24&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 25&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: red"&gt;Duration&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;cd0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Width&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 26&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DiscreteObjectKeyFrame&lt;/span&gt; &lt;span style="color: red"&gt;KeyTime&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;*&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 27&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 28&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;Storyboard&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;span style="color: teal"&gt; 29&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;vsm:VisualState&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Everything in there is actually repositioning the AccordionButton (header) and the
ExpandableContentControl (content) inside different grid cells. 
&lt;/p&gt;
&lt;p&gt;
In this case, you can imagine the header being in column 1 and the content taking
up column 2.
&lt;/p&gt;
&lt;p&gt;
You should not need to have to style an accordionItem itself that much. Most of the
template is just about positioning the Header versus the Content. The only reason
I see for restyling accordionItem is if you are unhappy with the defaults (easily
changed) or with the position of the header and content. All the other styling would
be done in either AccordionButton or ExpandableContentControl. Let me know if this
is not the case for your scenario.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=bf191966-f893-421c-949a-16d8e0e36106" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,bf191966-f893-421c-949a-16d8e0e36106.aspx</comments>
      <category>Silverlight;Silverlight Toolkit</category>
    </item>
    <item>
      <trackback:ping>http://www.sitechno.com/Blog/Trackback.aspx?guid=a7c3c2d9-9446-4236-bc6e-c436427002ff</trackback:ping>
      <pingback:server>http://www.sitechno.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sitechno.com/Blog/PermaLink,guid,a7c3c2d9-9446-4236-bc6e-c436427002ff.aspx</pingback:target>
      <dc:creator>Ruurd Boeke</dc:creator>
      <wfw:comment>http://www.sitechno.com/Blog/CommentView,guid,a7c3c2d9-9446-4236-bc6e-c436427002ff.aspx</wfw:comment>
      <wfw:commentRss>http://www.sitechno.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a7c3c2d9-9446-4236-bc6e-c436427002ff</wfw:commentRss>
      <slash:comments>50</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Accordion is a fun control with a lot of properties and options. I had great fun building
it and I hope you will have great fun while using it. This post gives an overview
of the control. Next parts will look into other controls that are used with Accordion.
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_thumb.png" width="428" height="216" />
          </a>
        </p>
        <p>
You can see a live demo <a href="http://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%201&amp;referringTitle=Home&amp;ANCHOR#Accordion" target="_blank">here</a>,
or go to our sample browser (<a href="http://silverlight.net/samples/sl2/toolkitcontrolsamples/run/default.html" target="_blank">SL2</a>, <a href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" target="_blank">SL3</a>)
to play around with the control. I have a little ‘studio’ there, that will allow you
to set some options and see how the control behaves.
</p>
        <p>
The Accordion shown in the picture above is build like this:
</p>
        <pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 1</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutToolkit:Accordion</span>
            <span style="color: red">x:Name</span>="<span style="color: blue">acc</span>" <span style="color: red">Grid.Column</span>="<span style="color: blue">0</span>" <span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 2</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutToolkit:AccordionItem</span>
            <span style="color: red">Content</span>="<span style="color: blue">item
1</span>" <span style="color: red">Header</span>="<span style="color: blue">A</span>"
/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 3</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutToolkit:AccordionItem</span>
            <span style="color: red">Content</span>="<span style="color: blue">item
2</span>" <span style="color: red">Header</span>="<span style="color: blue">B
- long header</span>" /<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: teal"> 4</span>
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">system:String</span>
            <span style="color: blue">&gt;</span>regular
string item 3<span style="color: blue">&lt;</span>/<span style="color: maroon">system:String</span><span style="color: blue">&gt;</span></pre>
          <span style="color: teal"> 5</span>
          <span style="color: blue">&lt;</span>/<span style="color: maroon">layoutToolkit:Accordion</span><span style="color: blue">&gt;</span></pre>
        <p>
As you can see, three items are added. The first two are AccordionItems, allowing
us to set a header and content. The last one is a String, which Accordion will wrap
in an AccordionItem behind the scenes. 
</p>
        <h3>Accordion
</h3>
        <p>
Accordion can be best described as an ItemsControl that displays Expanders. The items
shown are actually of type AccordionItem and can expand or collapse. 
<br />
We use the paradigm of Selection, instead of Expanding/Collapsing, so from now on
you will here me talk about a selected AccordionItem, which amounts to an expanded
AccordionItem.
</p>
        <p>
The Accordion class manages these AccordionItems and is responsible for the following:
</p>
        <ul>
          <li>
Easily styling the AccordionItems (ItemContainerStyle) 
</li>
          <li>
Setting a default ContentTemplate and HeaderTemplate 
</li>
          <li>
Setting the ExpandDirection 
</li>
          <li>
Single select and multi select. Actually, Accordion allows a couple of SelectionModes
that I will talk about 
</li>
          <li>
Managing a SelectedItem and SelectedIndex 
</li>
          <li>
Managing SelectedItems and SelectedIndices 
</li>
          <li>
Scheduling when a selected item is expanded or contracted (!) 
</li>
        </ul>
        <p>
Accordion manages AccordionItems just as ListBox would be managing ListBoxItems. Let’s
first look at the concepts that you know from other ItemControls and see how Accordion
handles them.
</p>
        <h5>ItemTemplate versus ContentTemplate and HeaderTemplate
</h5>
        <p>
When an item is added to an ItemsControl, Accordion will check if it is already an
instance of type AccordionItem. If it is not, the item will be wrapped inside an AccordionItem. 
<br />
You might expect to be able to define how your item will look with an ItemTemplate,
but that does not make that much sense, given that we expect you to want to set a
header and a content separately.
</p>
        <p>
Instead, Accordion exposes a ContentTemplate and HeaderTemplate DP. <em>There is some
talk to drop the ContentTemplate and just use the ItemTemplate for it, let me know
what your thoughts on that are.</em></p>
        <p>
I do make sure that both Content and Header datacontext is set appropriately, so you
might do something like this:
</p>
        <pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutToolkit:Accordion</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutToolkit:Accordion.ContentTemplate</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DataTemplate</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">StackPanel</span>
            <span style="color: red">Orientation</span>="<span style="color: blue">Horizontal</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">TextBlock</span>
            <span style="color: red">Text</span>="<span style="color: blue">Content:</span>"
/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">TextBlock</span>
            <span style="color: red">Text</span>="<span style="color: blue">{Binding}</span>"
/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>/<span style="color: maroon">StackPanel</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>/<span style="color: maroon">DataTemplate</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>/<span style="color: maroon">layoutToolkit:Accordion.ContentTemplate</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">layoutToolkit:Accordion.HeaderTemplate</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">DataTemplate</span>
            <span style="color: blue">&gt;</span>
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">StackPanel</span>
            <span style="color: red">Orientation</span>="<span style="color: blue">Horizontal</span>"<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">TextBlock</span>
            <span style="color: red">Text</span>="<span style="color: blue">Header:</span>"
/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">TextBlock</span>
            <span style="color: red">Text</span>="<span style="color: blue">{Binding}</span>"
/<span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>/<span style="color: maroon">StackPanel</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>/<span style="color: maroon">DataTemplate</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>/<span style="color: maroon">layoutToolkit:Accordion.HeaderTemplate</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
          </pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">System:String</span>
            <span style="color: blue">&gt;</span>hello<span style="color: blue">&lt;</span>/<span style="color: maroon">System:String</span><span style="color: blue">&gt;</span></pre>
          <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
            <span style="color: blue">&lt;</span>
            <span style="color: maroon">System:String</span>
            <span style="color: blue">&gt;</span>world<span style="color: blue">&lt;</span>/<span style="color: maroon">System:String</span><span style="color: blue">&gt;</span></pre>
          <span style="color: blue">&lt;</span>/<span style="color: maroon">layoutToolkit:Accordion</span><span style="color: blue">&gt;</span></pre>
        <p>
You would end up with an accordion that looks like:
</p>
        <p>
          <a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_thumb_2.png" width="114" height="69" />
          </a>
        </p>
        <p>
In my opinion there are two main scenario’s to use an itemscontrol like Accordion:
</p>
        <ol>
          <li>
Bind to businessobjects: use ContentTemplate and HeaderTemplate to determine what
is shown 
</li>
          <li>
Set items inline: use AccordionItem directly. 
</li>
        </ol>
        <h5>Selection
</h5>
        <p>
An Accordion allows for the following SelectionModes: One, OneOrMore, ZeroOrOne and
ZeroOrMore.
</p>
        <p>
Since there can be more than 1 item selected, Accordion supplies a few properties
(and events to match) to let you know what’s up:
</p>
        <ul>
          <li>
SelectedItem: The selected item. If Accordion allows multiple items, this property
will have the last selected item 
</li>
          <li>
SelectedIndex: The index of the selected item. This is necessary because you could
have multiple AccordionItems based on the same item. 
</li>
          <li>
SelectedItems: A collection of all the items that are selected. 
</li>
          <li>
SelectedIndices: A collection of indexes. 
</li>
        </ul>
        <p>
By setting a SelectionMode, the behavior of Accordion is changed quite profoundly.
When SelectionMode One or OneOrMore is chosen, Accordion will always make sure there
is at least one AccordionItem selected. It does so by making it impossible to unselect
an item if it is the last one selected. If no item is selected when the mode is set
to One*, the first item in the list will be auto-selected.
</p>
        <h5>ExpandDirection
</h5>
        <p>
You can specify in which direction the Accordion should open by setting an ExpandDirection
(Left, Right, Up, Down). I’ll go in-depth in how you can template your AccordionItems
appropriately. In the default template there is a little funky arrow that points to
the content, that arrow is repositioned according to the ExpandDirection.
</p>
        <h5>SelectionSequence
</h5>
        <p>
When the user selects an item, Accordion might have unselect another item (in the
ZeroOrOne or One modes). The de-selection will happen immediate, however, Accordion
gives you the option to influence when the actual animations happen. The SelectionSequence
property takes values of 'CollapseBeforeExpand’ and ‘Simultaneous’. 
</p>
        <p>
The CollapseBeforeExpand mode will actually schedule collapse animations before expands.
The effect is quite nice.
</p>
        <p>
Please let us know if you are interested in different scheduling schema’s. I can for
instance think of an Accordion that starts the next animation when it is halfway through
the first one. Not sure if it looks good though!
</p>
        <h5>The big one: Layout
</h5>
        <p>
Accordion will behave completely different when it has a fixed size versus no size.
In the first case, the items will share all the space amongst each other that the
parent has. In the latter, each item will take the space it desires.
</p>
        <p>
I will revisit the layout topic more in-depth, because there are a few intricacies
in how it works.
</p>
        <p>
--------
</p>
        <p>
Next parts will look at AccordionItem, ExpandableContentControl and LayoutTransformer. 
</p>
        <img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=a7c3c2d9-9446-4236-bc6e-c436427002ff" />
      </body>
      <title>Accordion, part 1</title>
      <guid isPermaLink="false">http://www.sitechno.com/Blog/PermaLink,guid,a7c3c2d9-9446-4236-bc6e-c436427002ff.aspx</guid>
      <link>http://www.sitechno.com/Blog/AccordionPart1.aspx</link>
      <pubDate>Mon, 23 Mar 2009 01:24:20 GMT</pubDate>
      <description>&lt;p&gt;
Accordion is a fun control with a lot of properties and options. I had great fun building
it and I hope you will have great fun while using it. This post gives an overview
of the control. Next parts will look into other controls that are used with Accordion.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_thumb.png" width="428" height="216" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
You can see a live demo &lt;a href="http://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%201&amp;amp;referringTitle=Home&amp;amp;ANCHOR#Accordion" target="_blank"&gt;here&lt;/a&gt;,
or go to our sample browser (&lt;a href="http://silverlight.net/samples/sl2/toolkitcontrolsamples/run/default.html" target="_blank"&gt;SL2&lt;/a&gt;, &lt;a href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" target="_blank"&gt;SL3&lt;/a&gt;)
to play around with the control. I have a little ‘studio’ there, that will allow you
to set some options and see how the control behaves.
&lt;/p&gt;
&lt;p&gt;
The Accordion shown in the picture above is build like this:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 1&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutToolkit:Accordion&lt;/span&gt; &lt;span style="color: red"&gt;x:Name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;acc&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Grid.Column&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 2&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutToolkit:AccordionItem&lt;/span&gt; &lt;span style="color: red"&gt;Content&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;item
1&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Header&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;A&lt;/span&gt;&amp;quot;
/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 3&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutToolkit:AccordionItem&lt;/span&gt; &lt;span style="color: red"&gt;Content&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;item
2&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Header&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;B
- long header&lt;/span&gt;&amp;quot; /&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: teal"&gt; 4&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;system:String&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;regular
string item 3&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;system:String&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;span style="color: teal"&gt; 5&lt;/span&gt; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;layoutToolkit:Accordion&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
As you can see, three items are added. The first two are AccordionItems, allowing
us to set a header and content. The last one is a String, which Accordion will wrap
in an AccordionItem behind the scenes. 
&lt;/p&gt;
&lt;h3&gt;Accordion
&lt;/h3&gt;
&lt;p&gt;
Accordion can be best described as an ItemsControl that displays Expanders. The items
shown are actually of type AccordionItem and can expand or collapse. 
&lt;br /&gt;
We use the paradigm of Selection, instead of Expanding/Collapsing, so from now on
you will here me talk about a selected AccordionItem, which amounts to an expanded
AccordionItem.
&lt;/p&gt;
&lt;p&gt;
The Accordion class manages these AccordionItems and is responsible for the following:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Easily styling the AccordionItems (ItemContainerStyle) 
&lt;/li&gt;
&lt;li&gt;
Setting a default ContentTemplate and HeaderTemplate 
&lt;/li&gt;
&lt;li&gt;
Setting the ExpandDirection 
&lt;/li&gt;
&lt;li&gt;
Single select and multi select. Actually, Accordion allows a couple of SelectionModes
that I will talk about 
&lt;/li&gt;
&lt;li&gt;
Managing a SelectedItem and SelectedIndex 
&lt;/li&gt;
&lt;li&gt;
Managing SelectedItems and SelectedIndices 
&lt;/li&gt;
&lt;li&gt;
Scheduling when a selected item is expanded or contracted (!) 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Accordion manages AccordionItems just as ListBox would be managing ListBoxItems. Let’s
first look at the concepts that you know from other ItemControls and see how Accordion
handles them.
&lt;/p&gt;
&lt;h5&gt;ItemTemplate versus ContentTemplate and HeaderTemplate
&lt;/h5&gt;
&lt;p&gt;
When an item is added to an ItemsControl, Accordion will check if it is already an
instance of type AccordionItem. If it is not, the item will be wrapped inside an AccordionItem. 
&lt;br /&gt;
You might expect to be able to define how your item will look with an ItemTemplate,
but that does not make that much sense, given that we expect you to want to set a
header and a content separately.
&lt;/p&gt;
&lt;p&gt;
Instead, Accordion exposes a ContentTemplate and HeaderTemplate DP. &lt;em&gt;There is some
talk to drop the ContentTemplate and just use the ItemTemplate for it, let me know
what your thoughts on that are.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
I do make sure that both Content and Header datacontext is set appropriately, so you
might do something like this:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutToolkit:Accordion&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutToolkit:Accordion.ContentTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;StackPanel&lt;/span&gt; &lt;span style="color: red"&gt;Orientation&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Horizontal&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;TextBlock&lt;/span&gt; &lt;span style="color: red"&gt;Text&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Content:&lt;/span&gt;&amp;quot;
/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;TextBlock&lt;/span&gt; &lt;span style="color: red"&gt;Text&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{Binding}&lt;/span&gt;&amp;quot;
/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;StackPanel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;layoutToolkit:Accordion.ContentTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          
&lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;layoutToolkit:Accordion.HeaderTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;StackPanel&lt;/span&gt; &lt;span style="color: red"&gt;Orientation&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Horizontal&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;TextBlock&lt;/span&gt; &lt;span style="color: red"&gt;Text&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Header:&lt;/span&gt;&amp;quot;
/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;TextBlock&lt;/span&gt; &lt;span style="color: red"&gt;Text&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;{Binding}&lt;/span&gt;&amp;quot;
/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;StackPanel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;layoutToolkit:Accordion.HeaderTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          
&lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;System:String&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;hello&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;System:String&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;          &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;System:String&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;world&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;System:String&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;layoutToolkit:Accordion&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
You would end up with an accordion that looks like:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sitechno.com/Blog/content/binary/WindowsLiveWriter/Accordionpart1_102BB/image_thumb_2.png" width="114" height="69" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In my opinion there are two main scenario’s to use an itemscontrol like Accordion:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Bind to businessobjects: use ContentTemplate and HeaderTemplate to determine what
is shown 
&lt;/li&gt;
&lt;li&gt;
Set items inline: use AccordionItem directly. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;h5&gt;Selection
&lt;/h5&gt;
&lt;p&gt;
An Accordion allows for the following SelectionModes: One, OneOrMore, ZeroOrOne and
ZeroOrMore.
&lt;/p&gt;
&lt;p&gt;
Since there can be more than 1 item selected, Accordion supplies a few properties
(and events to match) to let you know what’s up:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
SelectedItem: The selected item. If Accordion allows multiple items, this property
will have the last selected item 
&lt;/li&gt;
&lt;li&gt;
SelectedIndex: The index of the selected item. This is necessary because you could
have multiple AccordionItems based on the same item. 
&lt;/li&gt;
&lt;li&gt;
SelectedItems: A collection of all the items that are selected. 
&lt;/li&gt;
&lt;li&gt;
SelectedIndices: A collection of indexes. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
By setting a SelectionMode, the behavior of Accordion is changed quite profoundly.
When SelectionMode One or OneOrMore is chosen, Accordion will always make sure there
is at least one AccordionItem selected. It does so by making it impossible to unselect
an item if it is the last one selected. If no item is selected when the mode is set
to One*, the first item in the list will be auto-selected.
&lt;/p&gt;
&lt;h5&gt;ExpandDirection
&lt;/h5&gt;
&lt;p&gt;
You can specify in which direction the Accordion should open by setting an ExpandDirection
(Left, Right, Up, Down). I’ll go in-depth in how you can template your AccordionItems
appropriately. In the default template there is a little funky arrow that points to
the content, that arrow is repositioned according to the ExpandDirection.
&lt;/p&gt;
&lt;h5&gt;SelectionSequence
&lt;/h5&gt;
&lt;p&gt;
When the user selects an item, Accordion might have unselect another item (in the
ZeroOrOne or One modes). The de-selection will happen immediate, however, Accordion
gives you the option to influence when the actual animations happen. The SelectionSequence
property takes values of 'CollapseBeforeExpand’ and ‘Simultaneous’. 
&lt;/p&gt;
&lt;p&gt;
The CollapseBeforeExpand mode will actually schedule collapse animations before expands.
The effect is quite nice.
&lt;/p&gt;
&lt;p&gt;
Please let us know if you are interested in different scheduling schema’s. I can for
instance think of an Accordion that starts the next animation when it is halfway through
the first one. Not sure if it looks good though!
&lt;/p&gt;
&lt;h5&gt;The big one: Layout
&lt;/h5&gt;
&lt;p&gt;
Accordion will behave completely different when it has a fixed size versus no size.
In the first case, the items will share all the space amongst each other that the
parent has. In the latter, each item will take the space it desires.
&lt;/p&gt;
&lt;p&gt;
I will revisit the layout topic more in-depth, because there are a few intricacies
in how it works.
&lt;/p&gt;
&lt;p&gt;
--------
&lt;/p&gt;
&lt;p&gt;
Next parts will look at AccordionItem, ExpandableContentControl and LayoutTransformer. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sitechno.com/Blog/aggbug.ashx?id=a7c3c2d9-9446-4236-bc6e-c436427002ff" /&gt;</description>
      <comments>http://www.sitechno.com/Blog/CommentView,guid,a7c3c2d9-9446-4236-bc6e-c436427002ff.aspx</comments>
      <category>Silverlight;Silverlight Toolkit</category>
    </item>
  </channel>
</rss>
