kstanoev
12/15/2014 - 7:10 PM

Template of an expander control that works in Windows 8.1 and Windows Phone 8.1 apps.

Template of an expander control that works in Windows 8.1 and Windows Phone 8.1 apps.

<Style TargetType="local:ExpanderControl">
	<Setter Property="Template">
		<Setter.Value>
			<ControlTemplate TargetType="local:ExpanderControl">
				<Grid>
					<VisualStateManager.VisualStateGroups>
						<VisualStateGroup x:Name="ExpandStateGroup">
							<VisualState x:Name="Expanded">
								<Storyboard />
							</VisualState>
							<VisualState x:Name="Collapsed">
								<Storyboard />
							</VisualState>
						</VisualStateGroup>
					</VisualStateManager.VisualStateGroups>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="*" />
					</Grid.RowDefinitions>
					<ToggleButton Grid.Row="0" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded , Mode=TwoWay}" >
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>
							<ContentPresenter Grid.Column="0" Content="{TemplateBinding Header}" />
							<Path x:Name="arrow" Grid.Column="1" />
						</Grid>
					</ToggleButton>
					<Border Grid.Row="1" x:Name="PART_ExpandableContent" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded , Converter={StaticResource converter}}">
						<ContentPresenter  x:Name="PART_ExpandableContentPresenter" Content="{TemplateBinding Content}" />
					</Border>
				</Grid>
			</ControlTemplate>
		</Setter.Value>
	</Setter>
</Style>