<Styles xmlns="https://github.com/avaloniaui">
  <Design.PreviewWith>
    <Border Padding="20">
      <StackPanel Orientation="Vertical" Spacing="20" Width="350">
        <Expander ExpandDirection="Up" Header="Expand Up" CornerRadius="25">
          <Expander.Header>
            <Grid ColumnDefinitions="*, Auto">
              <TextBlock Grid.Column="0" Text="Expand" />
              <TextBlock Grid.Column="1" Text="Up" />
            </Grid>
          </Expander.Header>
          <StackPanel>
            <TextBlock>Expanded content</TextBlock>
          </StackPanel>
        </Expander>
        <Expander ExpandDirection="Down" Header="Expand Down" CornerRadius="25">
          <StackPanel>
            <TextBlock>Expanded content</TextBlock>
          </StackPanel>
        </Expander>
        <Expander ExpandDirection="Left" Header="Expand Left" CornerRadius="25">
          <StackPanel>
            <TextBlock>Expanded content</TextBlock>
          </StackPanel>
        </Expander>
        <Expander ExpandDirection="Right" Header="Expand Right" CornerRadius="25">
          <StackPanel>
            <TextBlock>Expanded content</TextBlock>
          </StackPanel>
        </Expander>
      </StackPanel>
    </Border>
  </Design.PreviewWith>
  <Style Selector="Expander">
    <Setter Property="ContentTransition">
      <Setter.Value>
        <CrossFade Duration="00:00:00.25" />
      </Setter.Value>
    </Setter>
  </Style>
  <Style Selector="Expander[ExpandDirection=Down]">
    <Setter Property="Template">
      <ControlTemplate>
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid RowDefinitions="Auto,*">
            <ToggleButton Name="PART_toggle" Grid.Row="0"
                          HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalAlignment}"
                          Content="{TemplateBinding Header}" IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" />
            <ContentPresenter Name="PART_ContentPresenter"
                              Grid.Row="1"
                              IsVisible="{TemplateBinding IsExpanded}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              Content="{TemplateBinding Content}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                              Padding="{TemplateBinding Padding}" />
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>
  <Style Selector="Expander[ExpandDirection=Up]">
    <Setter Property="Template">
      <ControlTemplate>
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid RowDefinitions="*,Auto">
            <ToggleButton Name="PART_toggle" Grid.Row="1"
                          HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalAlignment}"
                          Content="{TemplateBinding Header}" IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" />
            <ContentPresenter Name="PART_ContentPresenter"
                              Grid.Row="0"
                              IsVisible="{TemplateBinding IsExpanded}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              Content="{TemplateBinding Content}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                              Padding="{TemplateBinding Padding}" />
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>
  <Style Selector="Expander[ExpandDirection=Right]">
    <Setter Property="Template">
      <ControlTemplate>
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid ColumnDefinitions="Auto,*">
            <ToggleButton Name="PART_toggle" Grid.Column="0"
                          HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalAlignment}"
                          Content="{TemplateBinding Header}" IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" />
            <ContentPresenter Name="PART_ContentPresenter"
                              Grid.Column="1"
                              IsVisible="{TemplateBinding IsExpanded}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              Content="{TemplateBinding Content}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                              Padding="{TemplateBinding Padding}" />
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>
  <Style Selector="Expander[ExpandDirection=Left]">
    <Setter Property="Template">
      <ControlTemplate>
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid ColumnDefinitions="*,Auto">
            <ToggleButton Name="PART_toggle" Grid.Column="1"
                          HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalAlignment}"
                          Content="{TemplateBinding Header}" IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" />
            <ContentPresenter Name="PART_ContentPresenter"
                              Grid.Column="0"
                              IsVisible="{TemplateBinding IsExpanded}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              Content="{TemplateBinding Content}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                              Padding="{TemplateBinding Padding}" />
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>
  <Style Selector="Expander /template/ ToggleButton#PART_toggle">
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Template">
      <ControlTemplate>
        <Border BorderThickness="1" Background="{TemplateBinding Background}">
          <Grid ColumnDefinitions="Auto,*">
            <Border Grid.Column="0" Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center">
              <Path Fill="{DynamicResource ThemeForegroundBrush}"
                      HorizontalAlignment="Center"
                      VerticalAlignment="Center"
                      Data="M 0 2 L 4 6 L 0 10 Z" />
            </Border>
            <ContentPresenter Name="PART_ContentPresenter"
                              Grid.Column="1" 
                              Background="Transparent" 
                              Content="{TemplateBinding Content}" 
                              ContentTemplate="{Binding $parent[Expander].HeaderTemplate}"
                              VerticalAlignment="Center" 
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                              Padding="{TemplateBinding Padding}"/>
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>
  <Style Selector="Expander /template/ ToggleButton#PART_toggle:pointerover /template/ Border">
    <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
  </Style>
  <Style Selector="Expander:down:expanded /template/ ToggleButton#PART_toggle /template/ Path">
    <Setter Property="RenderTransform">
      <RotateTransform Angle="90" />
    </Setter>
  </Style>
  <Style Selector="Expander:up:expanded /template/ ToggleButton#PART_toggle /template/ Path">
    <Setter Property="RenderTransform">
      <RotateTransform Angle="-90" />
    </Setter>
  </Style>
  <Style Selector="Expander:left:expanded /template/ ToggleButton#PART_toggle /template/ Path">
    <Setter Property="RenderTransform">
      <RotateTransform Angle="180" />
    </Setter>
  </Style>
  <Style Selector="Expander:right /template/ ToggleButton#PART_toggle /template/ Path">
    <Setter Property="RenderTransform">
      <RotateTransform Angle="180" />
    </Setter>
  </Style>
  <Style Selector="Expander:right:expanded /template/ ToggleButton#PART_toggle /template/ Path">
    <Setter Property="RenderTransform">
      <RotateTransform Angle="0" />
    </Setter>
  </Style>
</Styles>
