Skip to content

Commit d8df238

Browse files
committed
Add SamplePanel
1 parent 297cd80 commit d8df238

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace DevWinUI;
5+
6+
public sealed partial class SamplePanel
7+
{
8+
public static readonly DependencyProperty HeaderProperty =
9+
DependencyProperty.Register(
10+
nameof(Header),
11+
typeof(string),
12+
typeof(SamplePanel),
13+
new PropertyMetadata(null));
14+
15+
public string? Header
16+
{
17+
get => (string?)GetValue(HeaderProperty);
18+
set => SetValue(HeaderProperty, value);
19+
}
20+
21+
22+
public static readonly DependencyProperty MainContentProperty =
23+
DependencyProperty.Register(
24+
nameof(MainContent),
25+
typeof(UIElement),
26+
typeof(SamplePanel),
27+
new PropertyMetadata(null));
28+
29+
public UIElement? MainContent
30+
{
31+
get => (UIElement?)GetValue(MainContentProperty);
32+
set => SetValue(MainContentProperty, value);
33+
}
34+
35+
36+
public static readonly DependencyProperty SideContentProperty =
37+
DependencyProperty.Register(
38+
nameof(SideContent),
39+
typeof(UIElement),
40+
typeof(SamplePanel),
41+
new PropertyMetadata(null));
42+
43+
public UIElement? SideContent
44+
{
45+
get => (UIElement?)GetValue(SideContentProperty);
46+
set => SetValue(SideContentProperty, value);
47+
}
48+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace DevWinUI;
5+
6+
public sealed partial class SamplePanel : Control
7+
{
8+
public SamplePanel()
9+
{
10+
DefaultStyleKey = typeof(SamplePanel);
11+
}
12+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
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+
<x:Double x:Key="SamplePanelSideContentWidth">360</x:Double>
7+
<Thickness x:Key="SamplePanelPadding">24</Thickness>
8+
9+
<Style TargetType="local:SamplePanel" BasedOn="{StaticResource DefaultSamplePanelStyle}" />
10+
11+
<Style x:Key="DefaultSamplePanelStyle" TargetType="local:SamplePanel">
12+
<Setter Property="Background" Value="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
13+
<Setter Property="BorderBrush" Value="{ThemeResource DividerStrokeColorDefaultBrush}" />
14+
<Setter Property="BorderThickness" Value="1" />
15+
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
16+
<Setter Property="Padding" Value="{ThemeResource SamplePanelPadding}" />
17+
<Setter Property="HorizontalAlignment" Value="Stretch" />
18+
<Setter Property="VerticalAlignment" Value="Center" />
19+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
20+
<Setter Property="IsTabStop" Value="True" />
21+
<Setter Property="UseSystemFocusVisuals" Value="True" />
22+
<Setter Property="IsFocusEngagementEnabled" Value="True" />
23+
<Setter Property="Template">
24+
<Setter.Value>
25+
<ControlTemplate TargetType="local:SamplePanel">
26+
<Grid x:Name="PART_RootGrid" RowSpacing="8">
27+
<Grid.RowDefinitions>
28+
<RowDefinition Height="Auto" />
29+
<RowDefinition Height="Auto" />
30+
</Grid.RowDefinitions>
31+
32+
<TextBlock Grid.Row="0"
33+
Style="{StaticResource BodyStrongTextBlockStyle}"
34+
Text="{Binding Header, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
35+
36+
<Grid x:Name="PART_RootPanel" Grid.Row="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}">
37+
<Grid.ColumnDefinitions>
38+
<ColumnDefinition Width="*" />
39+
<ColumnDefinition Width="Auto" />
40+
</Grid.ColumnDefinitions>
41+
42+
<ContentPresenter Grid.Column="0"
43+
Padding="{TemplateBinding Padding}"
44+
Content="{Binding MainContent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
45+
46+
<StackPanel Grid.Column="1" Width="{StaticResource SamplePanelSideContentWidth}" Padding="{TemplateBinding Padding}" Background="{ThemeResource LayerFillColorDefaultBrush}" BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}" BorderThickness="1,0,0,0" Spacing="12">
47+
48+
<ContentPresenter Margin="0,12,0,0"
49+
Content="{Binding SideContent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
50+
51+
</StackPanel>
52+
</Grid>
53+
</Grid>
54+
</ControlTemplate>
55+
</Setter.Value>
56+
</Setter>
57+
</Style>
58+
59+
</ResourceDictionary>

0 commit comments

Comments
 (0)