Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get the button on the right, you're going to have to re-template the expander. Here is the full xaml you'll need:</p> <pre><code>&lt;UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" x:Class="StackOverflowExpander.MainPage" mc:Ignorable="d" d:DesignHeight="100" d:DesignWidth="200"&gt; &lt;UserControl.Resources&gt; &lt;Style x:Key="ExpanderBottomRightButtonStyle" TargetType="toolkit:Expander"&gt; &lt;Setter Property="Background" Value="Transparent"/&gt; &lt;Setter Property="BorderBrush" Value="Transparent"/&gt; &lt;Setter Property="BorderThickness" Value="1"/&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"/&gt; &lt;Setter Property="VerticalContentAlignment" Value="Stretch"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="toolkit:Expander"&gt; &lt;Grid Background="Transparent"&gt; &lt;Grid.Resources&gt; &lt;LinearGradientBrush x:Key="ExpanderArrowFill" EndPoint="0,1" StartPoint="0,0"&gt; &lt;GradientStop Color="White" Offset="0"/&gt; &lt;GradientStop Color="#FFBFBFBF" Offset="0.5"/&gt; &lt;GradientStop Color="#FF878787" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="ExpanderArrowHoverFill" EndPoint="0,1" StartPoint="0,0"&gt; &lt;GradientStop Color="#FFF0F8FE" Offset="0"/&gt; &lt;GradientStop Color="#FFE0F3FE" Offset="0.3"/&gt; &lt;GradientStop Color="#FF6FA7C5" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="ExpanderArrowPressedFill" EndPoint="0,1" StartPoint="0,0"&gt; &lt;GradientStop Color="#FFDCF0FA" Offset="0"/&gt; &lt;GradientStop Color="#FFC5E6F7" Offset="0.2"/&gt; &lt;GradientStop Color="#FF5690D0" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;ControlTemplate x:Key="ExpanderDownHeaderTemplate" TargetType="ToggleButton"&gt; &lt;Grid Background="Transparent"&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="CheckStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="00:00:00"/&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Checked"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="Data"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="M 1,4.5 L 4.5,1 L 8,4.5"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Unchecked"/&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="CommonStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0"/&gt; &lt;VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/&gt; &lt;VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Normal"/&gt; &lt;VisualState x:Name="MouseOver"&gt; &lt;Storyboard&gt; &lt;ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF3C7FB1"/&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowHoverFill}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#222"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Pressed"&gt; &lt;Storyboard&gt; &lt;ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF526C7B"/&gt; &lt;DoubleAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="StrokeThickness" To="1.5"/&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowPressedFill}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#FF003366"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="FocusStates"&gt; &lt;VisualState x:Name="Focused"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Unfocused"/&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;Border Padding="{TemplateBinding Padding}"&gt; &lt;Grid Background="Transparent"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;ColumnDefinition Width="19"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"&gt; &lt;Ellipse Fill="{StaticResource ExpanderArrowFill}" Height="19" HorizontalAlignment="Center" x:Name="circle" Stroke="DarkGray" VerticalAlignment="Center" Width="19"/&gt; &lt;Path Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" x:Name="arrow" Stroke="#666" StrokeThickness="2" VerticalAlignment="Center"/&gt; &lt;/Grid&gt; &lt;ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="Left" Margin="4,0,0,0" x:Name="header" VerticalAlignment="Center"/&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;Rectangle IsHitTestVisible="false" x:Name="FocusVisualElement" Stroke="Green" StrokeDashArray="1 2" StrokeThickness="1" Visibility="Collapsed"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Grid.Resources&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="CommonStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0"/&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Normal"/&gt; &lt;VisualState x:Name="Disabled"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="FocusStates"&gt; &lt;VisualState x:Name="Focused"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Unfocused"/&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="ExpansionStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0"/&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Collapsed"/&gt; &lt;VisualState x:Name="Expanded"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="ExpandDirectionStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0"/&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="ExpandDown"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="rd1" Storyboard.TargetProperty="Height"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd0" Storyboard.TargetProperty="Width"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="ExpandUp"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="Template"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderUpHeaderTemplate}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="(Grid.Row)"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="1"/&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="rd0" Storyboard.TargetProperty="Height"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd0" Storyboard.TargetProperty="Width"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="ExpandLeft"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="Template"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderLeftHeaderTemplate}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="(Grid.Column)"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="1"/&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="rd0" Storyboard.TargetProperty="Height"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd0" Storyboard.TargetProperty="Width"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="*"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="ExpandRight"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="Template"&gt; &lt;DiscreteObjectKeyFrame KeyTime="00:00:00.1000000" Value="{StaticResource ExpanderLeftHeaderTemplate}"/&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;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;Border x:Name="Background" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3"&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;ToggleButton Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" Grid.Column="0" Grid.Row="0" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{TemplateBinding IsExpanded}" Margin="1" MinHeight="0" MinWidth="0" x:Name="ExpanderButton" Padding="{TemplateBinding Padding}" Template="{StaticResource ExpanderDownHeaderTemplate}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/&gt; &lt;ContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" Grid.Column="0" Grid.Row="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed"/&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Opacity="0" Background="#A5FFFFFF" CornerRadius="3"/&gt; &lt;Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" BorderThickness="1" CornerRadius="3"&gt; &lt;Border.BorderBrush&gt; &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#FFA3AEB9"/&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;/Border.BorderBrush&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;Grid x:Name="LayoutRoot" Background="White"&gt; &lt;toolkit:Expander Style="{StaticResource ExpanderBottomRightButtonStyle}"&gt; &lt;toolkit:Expander.Header&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="Horizontal1 "/&gt; &lt;TextBlock Text="Horizontal2 "/&gt; &lt;/StackPanel&gt; &lt;/toolkit:Expander.Header&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock Text="Vertical1"/&gt; &lt;TextBlock Text="Vertical2"/&gt; &lt;TextBlock Text="Vertical3"/&gt; &lt;/StackPanel&gt; &lt;/toolkit:Expander&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>This will produce a control that looks like this:</p> <p><img src="https://i.stack.imgur.com/FSqls.png" alt="enter image description here"></p> <p>If you can live with the button on the left, then the solution becomes alot easier:</p> <pre><code>&lt;toolkit:Expander&gt; &lt;toolkit:Expander.Header&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="Horizontal1 "/&gt; &lt;TextBlock Text="Horizontal2 "/&gt; &lt;/StackPanel&gt; &lt;/toolkit:Expander.Header&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock Text="Vertical1"/&gt; &lt;TextBlock Text="Vertical2"/&gt; &lt;TextBlock Text="Vertical3"/&gt; &lt;/StackPanel&gt; &lt;/toolkit:Expander&gt; </code></pre> <p>which produces this:</p> <p><img src="https://i.stack.imgur.com/3puFc.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload