Files
HandyControl/Net40/HandyControl_Net40/Themes/Styles/Expander.xaml
T
2019-01-21 11:12:38 +08:00

54 lines
3.6 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
<ResourceDictionary Source="ToggleButton.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="Expander">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="{DynamicResource TitleBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="MinHeight" Value="32"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Expander">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ToggleButton Padding="10,0,0,0" Foreground="{TemplateBinding Foreground}" Grid.ColumnSpan="2" HorizontalContentAlignment="Stretch" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Width="{TemplateBinding Width}" Height="{TemplateBinding MinHeight}" Style="{StaticResource ToggleButtonCustom}">
<ToggleButton.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="{TemplateBinding MinHeight}"/>
</Grid.ColumnDefinitions>
<ContentPresenter ContentSource="Header"/>
<ToggleButton Foreground="{TemplateBinding Foreground}" Grid.Column="1" Padding="0" Margin="0,0,10,0" Width="12" Height="12" VerticalAlignment="Center" HorizontalAlignment="Right" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" controls:IconSwitchElement.Geometry="{StaticResource DownGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}" Style="{StaticResource ToggleButtonIconTransparent}"/>
</Grid>
</ToggleButton.Content>
</ToggleButton>
<ContentPresenter Name="ExpandSite" Visibility="Collapsed" Grid.Row="1" Grid.Column="0"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="true">
<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value="2"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>