Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Material.Avalonia.Demo/Pages/ExpandersDemo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@
Content="{Binding }"
ContentTemplate="{StaticResource LoremContentTemplate}"/>

<Expander Header="This expander inflates content from upside!"
ExpandDirection="Up"
<Expander ExpandDirection="Up"
Content="{Binding }"
ContentTemplate="{StaticResource LoremContentTemplate}"/>
ContentTemplate="{StaticResource LoremContentTemplate}">
<Expander.Header>
<StackPanel Spacing="8">
<TextBlock Text="This expander inflates content from upside!" FontSize="20" FontWeight="Bold" />
<TextBlock Text="And the header height adjusts dynamically" FontSize="14" />
</StackPanel>
</Expander.Header>
</Expander>

<StackPanel Orientation="Horizontal">
<Expander Header="Inflates left!"
Expand Down
81 changes: 37 additions & 44 deletions Material.Styles/Resources/Themes/Expander.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:Material.Styles.Assists"
xmlns:controls="clr-namespace:Material.Styles.Controls">

<ControlTheme x:Key="ExpanderToggleButtonPart" TargetType="ToggleButton">
<Setter Property="Background" Value="Transparent" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="FocusAdorner" Value="{x:Null}"></Setter>
<Setter Property="Height" Value="48" />
<Setter Property="FocusAdorner" Value="{x:Null}"/>
<Setter Property="MinHeight" Value="48" />
<Setter Property="assists:ToggleButtonAssist.UncheckedBackground" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
Expand Down Expand Up @@ -51,7 +52,7 @@
</Transitions>
</Setter>
</Style>

<Style Selector="^:focus-visible">
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="BorderBrush" Value="{DynamicResource MaterialPrimaryLightBrush}"/>
Expand Down Expand Up @@ -127,22 +128,25 @@
assists:ShadowAssist.ShadowDepth="{TemplateBinding assists:ShadowAssist.ShadowDepth}">
<Border Name="PART_InnerBorder"
CornerRadius="{TemplateBinding CornerRadius}">
<Panel>
<controls:ContentExpandControl Name="PART_ContentExpand"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />

<LayoutTransformControl Name="PART_ToggleTransform">
<DockPanel>
<LayoutTransformControl Name="PART_ToggleTransform"
DockPanel.Dock="Top">
<ToggleButton Name="PART_ToggleButton"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Cursor="Hand"
Foreground="{DynamicResource MaterialBodyBrush}"
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" />
</LayoutTransformControl>
</Panel>

<controls:ContentExpandControl Name="PART_ContentExpand"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</DockPanel>

</Border>
</Border>
</ControlTemplate>
Expand Down Expand Up @@ -176,67 +180,56 @@
<Setter Property="Multiplier" Value="1" />
</Style>

<Style Selector="^:up">
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Vertical" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="Margin" Value="0,0,0,48" />
</Style>

<Style Selector="^:up">
<Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="DockPanel.Dock" Value="Bottom"/>
</Style>
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Vertical"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
</Style>

<Style Selector="^ /template/ ToggleButton#PART_ToggleButton">
<Setter Property="Theme" Value="{StaticResource UpExpanderToggleButtonPart}" />
</Style>
</Style>

<Style Selector="^:down">
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Vertical" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Margin" Value="0,48,0,0" />
</Style>

<Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="DockPanel.Dock" Value="Top"/>
</Style>
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Vertical"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>

<Style Selector="^ /template/ ToggleButton#PART_ToggleButton">
<Setter Property="Theme" Value="{StaticResource DownExpanderToggleButtonPart}" />
</Style>
</Style>

<Style Selector="^:left">
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Margin" Value="0,0,48,0" />
</Style>

<Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
<Setter Property="LayoutTransform" Value="rotate(90deg)" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="DockPanel.Dock" Value="Right"/>
</Style>
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Horizontal"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
</Style>

<Style Selector="^ /template/ ToggleButton#PART_ToggleButton">
<Setter Property="Theme" Value="{StaticResource LeftExpanderToggleButtonPart}" />
</Style>
</Style>

<Style Selector="^:right">
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Margin" Value="48,0,0,0" />
</Style>

<Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
<Setter Property="LayoutTransform" Value="rotate(90deg)" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="DockPanel.Dock" Value="Left"/>
</Style>
<Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
<Setter Property="Orientation" Value="Horizontal"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>

<Style Selector="^ /template/ ToggleButton#PART_ToggleButton">
<Setter Property="Theme" Value="{StaticResource RightExpanderToggleButtonPart}" />
</Style>
Expand All @@ -245,4 +238,4 @@

<ControlTheme x:Key="{x:Type Expander}" TargetType="Expander"
BasedOn="{StaticResource MaterialExpander}" />
</ResourceDictionary>
</ResourceDictionary>