Skip to content

Commit 64bca79

Browse files
committed
Add Support Nested SettingsExpander
1 parent 489dadc commit 64bca79

3 files changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace DevWinUI;
2+
3+
internal sealed partial class CustomSettingsExpanderItemStyleSelector : SettingsExpanderItemStyleSelector
4+
{
5+
public Style ExpanderStyle { get; set; }
6+
7+
protected override Style SelectStyleCore(object item, DependencyObject container)
8+
{
9+
switch (container)
10+
{
11+
case SettingsCard:
12+
return base.SelectStyleCore(item, container);
13+
case SettingsExpander:
14+
return ExpanderStyle;
15+
}
16+
17+
return null;
18+
}
19+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="using:DevWinUI">
5+
6+
<local:CustomSettingsExpanderItemStyleSelector x:Key="CustomSettingsExpanderItemStyleSelector" ClickableStyle="{StaticResource ClickableSettingsExpanderItemStyle}" DefaultStyle="{StaticResource DefaultSettingsExpanderItemStyle}" ExpanderStyle="{StaticResource DefaultNestedSettingsExpanderStyle}" />
7+
8+
<local:CustomSettingsExpanderItemStyleSelector x:Key="NestedCustomSettingsExpanderItemStyleSelector" ClickableStyle="{StaticResource DefaultNestedClickableSettingsCardStyle}" DefaultStyle="{StaticResource DefaultNestedSettingsCardStyle}" />
9+
10+
<Style x:Key="DefaultNestedSettingsCardStyle" BasedOn="{StaticResource DefaultSettingsCardStyle}" TargetType="local:SettingsCard">
11+
<Setter Property="Padding" Value="116,8,44,8" />
12+
</Style>
13+
14+
<Style x:Key="DefaultNestedClickableSettingsCardStyle" BasedOn="{StaticResource DefaultSettingsExpanderItemStyle}" TargetType="local:SettingsCard">
15+
<Style.Setters>
16+
<Setter Property="Padding" Value="116,8,16,8" />
17+
</Style.Setters>
18+
</Style>
19+
20+
<Style x:Key="DefaultNestedSettingsExpanderStyle" BasedOn="{StaticResource DefaultSettingsExpanderStyle}" TargetType="local:SettingsExpander">
21+
<Setter Property="Padding" Value="{StaticResource SettingsExpanderItemPadding}" />
22+
<Setter Property="CornerRadius" Value="0" />
23+
<Setter Property="Template">
24+
<Setter.Value>
25+
<ControlTemplate TargetType="local:SettingsExpander">
26+
<Expander MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" CornerRadius="{TemplateBinding CornerRadius}" IsExpanded="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource SettingsExpanderExpanderStyle}">
27+
<Expander.Header>
28+
<local:SettingsCard Padding="{TemplateBinding Padding}" VerticalAlignment="Center" Background="Transparent" BorderThickness="0" Content="{TemplateBinding Content}" Description="{TemplateBinding Description}" FontFamily="{TemplateBinding FontFamily}" Header="{TemplateBinding Header}" HeaderIcon="{TemplateBinding HeaderIcon}" IsClickEnabled="False" />
29+
</Expander.Header>
30+
<Expander.Content>
31+
<Grid CornerRadius="{Binding CornerRadius, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource CornerRadiusConverter}}">
32+
<Grid.RowDefinitions>
33+
<RowDefinition Height="Auto" />
34+
<RowDefinition Height="*" />
35+
<RowDefinition Height="Auto" />
36+
</Grid.RowDefinitions>
37+
<ContentPresenter Content="{TemplateBinding ItemsHeader}" />
38+
<ItemsRepeater x:Name="PART_ItemsRepeater" Grid.Row="1" ItemTemplate="{Binding ItemTemplate, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" TabFocusNavigation="Local">
39+
<ItemsRepeater.Layout>
40+
<StackLayout Orientation="Vertical" />
41+
</ItemsRepeater.Layout>
42+
</ItemsRepeater>
43+
<ContentPresenter Grid.Row="2" Content="{TemplateBinding ItemsFooter}" />
44+
</Grid>
45+
</Expander.Content>
46+
</Expander>
47+
</ControlTemplate>
48+
</Setter.Value>
49+
</Setter>
50+
</Style>
51+
</ResourceDictionary>

dev/DevWinUI/Themes/Generic.xaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Controls\Ported\LoopingSelector\LoopingSelector.xaml
2222
Controls\Ported\PagerControl\PagerControl.xaml
2323
Controls\Ported\SamplePanel\SamplePanel.xaml
2424
Controls\Ported\SettingsCard\SettingsCard.xaml
25+
Controls\Ported\SettingsCardAndExpander\SettingsCardAndExpander.xaml
2526
Controls\Ported\SettingsExpander\SettingsExpander.xaml
2627
Controls\Ported\Sidebar\SidebarStyles.xaml
2728
Controls\Ported\Sidebar\SidebarView.ThemeResources.xaml
@@ -18405,6 +18406,9 @@ Themes\Styles\Controls\WaveProgressBar.xaml
1840518406
</Setter>
1840618407
</Style.Setters>
1840718408
</Style>
18409+
<Style x:Key="DefaultNestedSettingsCardStyle" BasedOn="{StaticResource DefaultSettingsCardStyle}" TargetType="local:SettingsCard">
18410+
<Setter Property="Padding" Value="116,8,44,8" />
18411+
</Style>
1840818412
<Style x:Key="DefaultSettingsExpanderItemStyle" BasedOn="{StaticResource DefaultSettingsCardStyle}" TargetType="local:SettingsCard">
1840918413
<Style.Setters>
1841018414
<Setter Property="BorderThickness" Value="{ThemeResource SettingsExpanderItemBorderThickness}" />
@@ -18825,6 +18829,11 @@ Themes\Styles\Controls\WaveProgressBar.xaml
1882518829
<Style BasedOn="{StaticResource DefaultWaveProgressBarStyle}" TargetType="local:WaveProgressBar" />
1882618830
<Style BasedOn="{StaticResource DefaultBreadcrumbBarItemStyle}" TargetType="local:BreadcrumbBarItem" />
1882718831
<Style BasedOn="{StaticResource DefaultSettingsCardStyle}" TargetType="local:SettingsCard" />
18832+
<Style x:Key="DefaultNestedClickableSettingsCardStyle" BasedOn="{StaticResource DefaultSettingsExpanderItemStyle}" TargetType="local:SettingsCard">
18833+
<Style.Setters>
18834+
<Setter Property="Padding" Value="116,8,16,8" />
18835+
</Style.Setters>
18836+
</Style>
1882818837
<Style x:Key="DefaultSettingsExpanderStyle" TargetType="local:SettingsExpander">
1882918838
<Style.Setters>
1883018839
<Setter Property="Background" Value="{ThemeResource SettingsCardBackground}" />
@@ -19105,5 +19114,36 @@ Themes\Styles\Controls\WaveProgressBar.xaml
1910519114
<Style BasedOn="{StaticResource DefaultOutOfBoxPageStyle}" TargetType="local:OutOfBoxPage" />
1910619115
<Style BasedOn="{StaticResource DefaultPinBoxStyle}" TargetType="local:PinBox" />
1910719116
<Style BasedOn="{StaticResource DefaultStepBarStyle}" TargetType="local:StepBar" />
19117+
<Style x:Key="DefaultNestedSettingsExpanderStyle" BasedOn="{StaticResource DefaultSettingsExpanderStyle}" TargetType="local:SettingsExpander">
19118+
<Setter Property="Padding" Value="{StaticResource SettingsExpanderItemPadding}" />
19119+
<Setter Property="CornerRadius" Value="0" />
19120+
<Setter Property="Template">
19121+
<Setter.Value>
19122+
<ControlTemplate TargetType="local:SettingsExpander">
19123+
<Expander MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" CornerRadius="{TemplateBinding CornerRadius}" IsExpanded="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource SettingsExpanderExpanderStyle}">
19124+
<Expander.Header>
19125+
<local:SettingsCard Padding="{TemplateBinding Padding}" VerticalAlignment="Center" Background="Transparent" BorderThickness="0" Content="{TemplateBinding Content}" Description="{TemplateBinding Description}" FontFamily="{TemplateBinding FontFamily}" Header="{TemplateBinding Header}" HeaderIcon="{TemplateBinding HeaderIcon}" IsClickEnabled="False" />
19126+
</Expander.Header>
19127+
<Expander.Content>
19128+
<Grid CornerRadius="{Binding CornerRadius, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource CornerRadiusConverter}}">
19129+
<Grid.RowDefinitions>
19130+
<RowDefinition Height="Auto" />
19131+
<RowDefinition Height="*" />
19132+
<RowDefinition Height="Auto" />
19133+
</Grid.RowDefinitions>
19134+
<ContentPresenter Content="{TemplateBinding ItemsHeader}" />
19135+
<ItemsRepeater x:Name="PART_ItemsRepeater" Grid.Row="1" ItemTemplate="{Binding ItemTemplate, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" TabFocusNavigation="Local">
19136+
<ItemsRepeater.Layout>
19137+
<StackLayout Orientation="Vertical" />
19138+
</ItemsRepeater.Layout>
19139+
</ItemsRepeater>
19140+
<ContentPresenter Grid.Row="2" Content="{TemplateBinding ItemsFooter}" />
19141+
</Grid>
19142+
</Expander.Content>
19143+
</Expander>
19144+
</ControlTemplate>
19145+
</Setter.Value>
19146+
</Setter>
19147+
</Style>
1910819148
<Style BasedOn="{StaticResource DefaultSettingsExpanderStyle}" TargetType="local:SettingsExpander" />
1910919149
</ResourceDictionary>

0 commit comments

Comments
 (0)