Stretch content in an AccordionItem

1 Nov

One of the controls that you can get for free with the Silverlight Toolkit is an Accordion. It represents a collection of collapsed and expanded AccordionItem controls.

If you wish to add content to your AccordionItems you just put it inside the AccordionItem tags. If you wants to stretch your content inside the AccordionItem you need set the Horizontal-/VerticalContentAlignment=”Stretch on the AccordionItem. If you just set the Horizontal-/VerticalAlignment it wont have any effect.

<layouttoolkit:Accordion ExpandDirection="Left"
                         HorizontalAlignment="Stretch"
                         VerticalAlignment="Stretch">
    <layouttoolkit:AccordionItem Header="Hello World"
                                 HorizontalContentAlignment="Stretch"
                                 VerticalContentAlignment="Stretch">
        ...
    </layouttoolkit:AccordionItem>
</layouttoolkit:Accordion>

The reason why you need this approach is because the ControlTemplate of the AccordingItem is using TemplateBinding to set the Horizontal-/VerticalAlignment.

HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 

by xamlgeek

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: