Skip to content

Commit 33a7d68

Browse files
committed
Chore: Refactoring & Cleanup & Docs
1 parent 7ad7a22 commit 33a7d68

File tree

1 file changed

+75
-38
lines changed

1 file changed

+75
-38
lines changed

Source/NETworkManager/Resources/Styles/ExpanderStyles.xaml

Lines changed: 75 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,43 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:mahAppsControls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
44
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks">
5-
<Style x:Key="ExpanderDownHeader" BasedOn="{StaticResource MahApps.Styles.ToggleButton.ExpanderHeader.Down}" TargetType="{x:Type ToggleButton}">
5+
<Style x:Key="ExpanderDownHeader"
6+
BasedOn="{StaticResource ResourceKey=MahApps.Styles.ToggleButton.ExpanderHeader.Down}"
7+
TargetType="{x:Type TypeName=ToggleButton}">
68
<Setter Property="Template">
79
<Setter.Value>
8-
<ControlTemplate TargetType="{x:Type ToggleButton}">
9-
<Border Padding="{TemplateBinding Padding}"
10-
Background="{TemplateBinding Background}"
11-
BorderBrush="{TemplateBinding BorderBrush}"
12-
BorderThickness="{TemplateBinding BorderThickness}">
10+
<ControlTemplate TargetType="{x:Type TypeName=ToggleButton}">
11+
<Border Padding="{TemplateBinding Property=Padding}"
12+
Background="{TemplateBinding Property=Background}"
13+
BorderBrush="{TemplateBinding Property=BorderBrush}"
14+
BorderThickness="{TemplateBinding Property=BorderThickness}">
1315
<Grid Background="Transparent" SnapsToDevicePixels="False">
1416
<Grid.ColumnDefinitions>
1517
<ColumnDefinition Width="Auto" />
1618
<ColumnDefinition Width="*" />
1719
</Grid.ColumnDefinitions>
18-
<Rectangle Grid.Column="0" x:Name="Chevron" Width="16" Height="16" Fill="{DynamicResource MahApps.Brushes.Gray3}" VerticalAlignment="Center">
20+
<Rectangle Grid.Column="0" Grid.Row="0"
21+
x:Name="Chevron"
22+
Width="16" Height="16"
23+
Fill="{DynamicResource ResourceKey=MahApps.Brushes.Gray3}"
24+
VerticalAlignment="Center">
1925
<Rectangle.OpacityMask>
2026
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=ChevronUp}" />
2127
</Rectangle.OpacityMask>
2228
</Rectangle>
2329
<mahAppsControls:ContentControlEx Grid.Column="1"
2430
Margin="10,0,0,0"
2531
HorizontalAlignment="Stretch"
26-
Padding="{TemplateBinding Padding}"
27-
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
28-
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
29-
Content="{TemplateBinding Content}"
30-
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mahAppsControls:ControlsHelper.ContentCharacterCasing)}"
31-
ContentStringFormat="{TemplateBinding ContentStringFormat}"
32-
ContentTemplate="{TemplateBinding ContentTemplate}"
33-
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
32+
Padding="{TemplateBinding Property=Padding}"
33+
HorizontalContentAlignment="{TemplateBinding Property=HorizontalContentAlignment}"
34+
VerticalContentAlignment="{TemplateBinding Property=VerticalContentAlignment}"
35+
Content="{TemplateBinding Property=Content}"
36+
ContentCharacterCasing="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(mahAppsControls:ControlsHelper.ContentCharacterCasing)}"
37+
ContentStringFormat="{TemplateBinding Property=ContentStringFormat}"
38+
ContentTemplate="{TemplateBinding Property=ContentTemplate}"
39+
ContentTemplateSelector="{TemplateBinding Property=ContentTemplateSelector}"
3440
RecognizesAccessKey="True"
35-
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
41+
SnapsToDevicePixels="{TemplateBinding Property=SnapsToDevicePixels}">
3642
</mahAppsControls:ContentControlEx>
3743
</Grid>
3844
</Border>
@@ -45,47 +51,70 @@
4551
</Setter>
4652
</Trigger>
4753
<Trigger Property="IsMouseOver" Value="True">
48-
<Setter TargetName="Chevron" Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray5}"/>
54+
<Setter TargetName="Chevron" Property="Fill"
55+
Value="{DynamicResource ResourceKey=MahApps.Brushes.Gray5}"/>
4956
</Trigger>
5057
</ControlTemplate.Triggers>
5158
</ControlTemplate>
5259
</Setter.Value>
5360
</Setter>
5461
</Style>
5562

56-
<Style x:Key="DefaultExpander" TargetType="{x:Type Expander}" BasedOn="{StaticResource MahApps.Styles.Expander}">
63+
<Style x:Key="DefaultExpander"
64+
TargetType="{x:Type TypeName=Expander}"
65+
BasedOn="{StaticResource ResourceKey=MahApps.Styles.Expander}">
5766
<Setter Property="BorderThickness" Value="0" />
5867
<Setter Property="ExpandDirection" Value="Down" />
5968
<Setter Property="Padding" Value="0" />
60-
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderBackground" Value="Transparent" />
61-
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderForeground" Value="{StaticResource MahApps.Brushes.Gray3}" />
62-
<Setter Property="mahAppsControls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
63-
<Setter Property="mahAppsControls:ExpanderHelper.HeaderDownStyle" Value="{DynamicResource ExpanderDownHeader}" />
69+
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderBackground"
70+
Value="Transparent" />
71+
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderForeground"
72+
Value="{StaticResource ResourceKey=MahApps.Brushes.Gray3}" />
73+
<Setter Property="mahAppsControls:ControlsHelper.ContentCharacterCasing"
74+
Value="Normal" />
75+
<Setter Property="mahAppsControls:ExpanderHelper.HeaderDownStyle"
76+
Value="{DynamicResource ResourceKey=ExpanderDownHeader}" />
6477
</Style>
6578

66-
<Style x:Key="ProfileExpanderOpen" BasedOn="{StaticResource MahApps.Styles.ToggleButton.ExpanderHeader.Down}" TargetType="{x:Type ToggleButton}">
79+
<Style x:Key="ProfileExpanderOpen"
80+
BasedOn="{StaticResource ResourceKey=MahApps.Styles.ToggleButton.ExpanderHeader.Down}"
81+
TargetType="{x:Type TypeName=ToggleButton}">
6782
<Setter Property="Template" Value="{x:Null}" />
6883
</Style>
6984

70-
<Style x:Key="ProfileExpanderClosed" BasedOn="{StaticResource MahApps.Styles.ToggleButton.ExpanderHeader.Right}" TargetType="{x:Type ToggleButton}">
85+
<Style x:Key="ProfileExpanderClosed"
86+
BasedOn="{StaticResource ResourceKey=MahApps.Styles.ToggleButton.ExpanderHeader.Right}"
87+
TargetType="{x:Type TypeName=ToggleButton}">
7188
<Setter Property="Template">
7289
<Setter.Value>
73-
<ControlTemplate TargetType="{x:Type ToggleButton}">
74-
<Border Padding="{TemplateBinding Padding}"
75-
Background="{TemplateBinding Background}"
76-
BorderBrush="{TemplateBinding BorderBrush}"
77-
BorderThickness="{TemplateBinding BorderThickness}">
90+
<ControlTemplate TargetType="{x:Type TypeName=ToggleButton}">
91+
<Border Padding="{TemplateBinding Property=Padding}"
92+
Background="{TemplateBinding Property=Background}"
93+
BorderBrush="{TemplateBinding Property=BorderBrush}"
94+
BorderThickness="{TemplateBinding Property=BorderThickness}">
7895
<Grid Background="Transparent" SnapsToDevicePixels="False">
7996
<Grid.RowDefinitions>
8097
<RowDefinition Height="Auto" />
8198
<RowDefinition Height="*" />
8299
</Grid.RowDefinitions>
83-
<Rectangle Grid.Row="0" x:Name="Chevron" Width="16" Height="16" Fill="{DynamicResource MahApps.Brushes.Gray3}" Margin="10,15,10,10" VerticalAlignment="Center" HorizontalAlignment="Center">
100+
<Rectangle Grid.Row="0" x:Name="Chevron"
101+
Width="16" Height="16"
102+
Fill="{DynamicResource ResourceKey=MahApps.Brushes.Gray3}" Margin="10,15,10,10"
103+
VerticalAlignment="Center"
104+
HorizontalAlignment="Center">
84105
<Rectangle.OpacityMask>
85106
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=ChevronLeft}" />
86107
</Rectangle.OpacityMask>
87108
</Rectangle>
88-
<TextBlock Grid.Row="1" Text="{TemplateBinding Content}" TextOptions.TextFormattingMode="Display" Foreground="{TemplateBinding Foreground}" Style="{StaticResource DefaultTextBlock}" FontSize="18" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center">
109+
<TextBlock Grid.Row="1"
110+
Text="{TemplateBinding Property=Content}"
111+
TextOptions.TextFormattingMode="Display"
112+
Foreground="{TemplateBinding Property=Foreground}"
113+
Style="{StaticResource ResourceKey=DefaultTextBlock}"
114+
FontSize="18"
115+
Margin="0"
116+
VerticalAlignment="Center"
117+
HorizontalAlignment="Center">
89118
<TextBlock.LayoutTransform>
90119
<RotateTransform Angle="-90" />
91120
</TextBlock.LayoutTransform>
@@ -94,26 +123,34 @@
94123
</Border>
95124
<ControlTemplate.Triggers>
96125
<Trigger Property="IsMouseOver" Value="True">
97-
<Setter TargetName="Chevron" Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray5}"/>
126+
<Setter TargetName="Chevron" Property="Fill"
127+
Value="{DynamicResource ResourceKey=MahApps.Brushes.Gray5}"/>
98128
</Trigger>
99129
</ControlTemplate.Triggers>
100130
</ControlTemplate>
101131
</Setter.Value>
102132
</Setter>
103133
</Style>
104134

105-
<Style x:Key="ProfileExpander" TargetType="{x:Type Expander}" BasedOn="{StaticResource MahApps.Styles.Expander}">
135+
<Style x:Key="ProfileExpander"
136+
TargetType="{x:Type TypeName=Expander}"
137+
BasedOn="{StaticResource ResourceKey=MahApps.Styles.Expander}">
106138
<Setter Property="BorderThickness" Value="0" />
107139
<Setter Property="ExpandDirection" Value="Right" />
108140
<Setter Property="Padding" Value="10" />
109-
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderBackground" Value="Transparent" />
110-
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderForeground" Value="{StaticResource MahApps.Brushes.Gray3}" />
111-
<Setter Property="mahAppsControls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
112-
<Setter Property="mahAppsControls:ExpanderHelper.HeaderRightStyle" Value="{DynamicResource ProfileExpanderClosed}" />
141+
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderBackground"
142+
Value="Transparent" />
143+
<Setter Property="mahAppsControls:HeaderedControlHelper.HeaderForeground"
144+
Value="{StaticResource ResourceKey=MahApps.Brushes.Gray3}" />
145+
<Setter Property="mahAppsControls:ControlsHelper.ContentCharacterCasing"
146+
Value="Normal" />
147+
<Setter Property="mahAppsControls:ExpanderHelper.HeaderRightStyle"
148+
Value="{DynamicResource ResourceKey=ProfileExpanderClosed}" />
113149
<Style.Triggers>
114150
<Trigger Property="IsExpanded" Value="True">
115151
<Setter Property="ExpandDirection" Value="Down" />
116-
<Setter Property="mahAppsControls:ExpanderHelper.HeaderDownStyle" Value="{DynamicResource ProfileExpanderOpen}" />
152+
<Setter Property="mahAppsControls:ExpanderHelper.HeaderDownStyle"
153+
Value="{DynamicResource ResourceKey=ProfileExpanderOpen}" />
117154
</Trigger>
118155
</Style.Triggers>
119156
</Style>

0 commit comments

Comments
 (0)