您可以更改擴展的背景:
<Expander IsExpanded="True" Background="Red">
或者,如果你想保持Mahapps的主題,你應該使用Mahapps預定義的畫筆之一,並更改擴展樣式,因爲擴展相關與積極的口音。
編輯
這種風格添加到資源:
<Style x:Key="CustomExpanderHeaderStyle" BasedOn="{DynamicResource ExpanderUpHeaderStyle}"
TargetType="{x:Type ToggleButton}">
<Setter Property="Height" Value="45"/>
<Setter Property="Background" Value="Red"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid Background="Transparent" SnapsToDevicePixels="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Ellipse x:Name="Circle"
Width="19"
Height="19"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="{TemplateBinding Foreground}" />
<Path x:Name="Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2"
Data="M 1,1.5 L 4.5,5 L 8,1.5"
SnapsToDevicePixels="false" />
<controls:ContentControlEx Grid.Column="1"
Margin="4 0 0 0"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(controls:ControlsHelper.ContentCharacterCasing)}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="Arrow" Property="Data" Value="M 1,4.5 L 4.5,1 L 8,4.5" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Arrow" Property="Stroke" Value="{DynamicResource GrayBrush2}" />
<Setter TargetName="Circle" Property="Stroke" Value="{DynamicResource GrayBrush2}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Arrow" Property="Stroke" Value="{DynamicResource BlackColorBrush}" />
<Setter TargetName="Circle" Property="Stroke" Value="{DynamicResource BlackColorBrush}" />
<Setter TargetName="Circle" Property="StrokeThickness" Value="2" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
在GroupStyle:
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander controls:ExpanderHelper.HeaderDownStyle="{StaticResource CustomExpanderHeaderStyle}" IsExpanded="True">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Gray" FontSize="22" VerticalAlignment="Bottom" />
<TextBlock Text="{Binding ItemCount}" FontSize="22" Foreground="Green" FontWeight="Bold" FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" />
<TextBlock Text=" Campionati" FontSize="22" Foreground="Silver" FontStyle="Italic" VerticalAlignment="Bottom" />
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
不要忘記補充的xmlns:
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
和fot的高度? – Heisenberg
好的,我將編輯帖子。 –
在ExpanderHeaderStyle中設置高度和背景。 –