Skip to content

Commit bc0d44e

Browse files
committed
add in Drawer
add in Drawer
1 parent 9d8eaec commit bc0d44e

File tree

10 files changed

+460
-0
lines changed

10 files changed

+460
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<UserControl
2+
x:Class="WPFDevelopers.Samples.ExampleViews.DrawerExample"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
10+
d:DesignHeight="450"
11+
d:DesignWidth="800"
12+
mc:Ignorable="d">
13+
<controls:CodeViewer>
14+
<Grid>
15+
<Grid.ColumnDefinitions>
16+
<ColumnDefinition />
17+
<ColumnDefinition />
18+
</Grid.ColumnDefinitions>
19+
<Grid.RowDefinitions>
20+
<RowDefinition />
21+
<RowDefinition />
22+
</Grid.RowDefinitions>
23+
<wd:Drawer
24+
x:Name="MyDrawerTop"
25+
Margin="2"
26+
Position="Top">
27+
<wd:Drawer.Header>
28+
<Grid Height="120">
29+
<StackPanel HorizontalAlignment="Center">
30+
<TextBlock FontSize="18" Text="Drawer" />
31+
<Button HorizontalAlignment="Center" Content="contents..." />
32+
</StackPanel>
33+
</Grid>
34+
</wd:Drawer.Header>
35+
<wd:Drawer.Content>
36+
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom">
37+
<TextBlock Text="抽屉从顶部置滑出,点击遮罩区关闭。" />
38+
<Button
39+
Margin="0,10"
40+
HorizontalAlignment="Center"
41+
Click="ButtonTop_Click"
42+
Content="Open"
43+
Style="{StaticResource WD.PrimaryButton}" />
44+
</StackPanel>
45+
</wd:Drawer.Content>
46+
</wd:Drawer>
47+
<wd:Drawer
48+
x:Name="MyDrawerBottom"
49+
Grid.Column="1"
50+
Margin="2"
51+
wd:ElementHelper.CornerRadius="3"
52+
Position="Bottom">
53+
<wd:Drawer.Header>
54+
<Grid Height="130">
55+
<StackPanel HorizontalAlignment="Center">
56+
<TextBlock FontSize="18" Text="Drawer" />
57+
<Button
58+
HorizontalAlignment="Center"
59+
wd:ElementHelper.CornerRadius="3"
60+
Content="contents..."
61+
Style="{StaticResource WD.DangerDefaultButton}" />
62+
</StackPanel>
63+
</Grid>
64+
</wd:Drawer.Header>
65+
<wd:Drawer.Content>
66+
<StackPanel HorizontalAlignment="Center">
67+
<TextBlock Text="抽屉从底部滑出,点击遮罩区关闭。" />
68+
<Button
69+
Margin="0,10"
70+
HorizontalAlignment="Center"
71+
wd:ElementHelper.CornerRadius="3"
72+
Click="ButtonBottom_Click"
73+
Content="Open"
74+
Style="{StaticResource WD.DangerPrimaryButton}" />
75+
</StackPanel>
76+
</wd:Drawer.Content>
77+
</wd:Drawer>
78+
79+
<wd:Drawer
80+
x:Name="MyDrawerLeft"
81+
Grid.Row="1"
82+
Margin="2"
83+
wd:ElementHelper.CornerRadius="3"
84+
Position="Left">
85+
<wd:Drawer.Header>
86+
<Grid Width="140" Background="HotPink">
87+
<StackPanel>
88+
<TextBlock
89+
HorizontalAlignment="Center"
90+
FontSize="18"
91+
Text="Drawer" />
92+
<Button
93+
HorizontalAlignment="Center"
94+
wd:ElementHelper.CornerRadius="3"
95+
Content="contents..."
96+
Style="{StaticResource WD.SuccessDefaultButton}" />
97+
</StackPanel>
98+
</Grid>
99+
</wd:Drawer.Header>
100+
<wd:Drawer.Content>
101+
<StackPanel HorizontalAlignment="Center">
102+
<TextBlock Text="抽屉从左侧滑出,点击遮罩区关闭。" />
103+
<Button
104+
Margin="0,10"
105+
HorizontalAlignment="Center"
106+
wd:ElementHelper.CornerRadius="3"
107+
Click="ButtonLeft_Click"
108+
Content="Open"
109+
Style="{StaticResource WD.SuccessPrimaryButton}" />
110+
</StackPanel>
111+
</wd:Drawer.Content>
112+
</wd:Drawer>
113+
<wd:Drawer
114+
x:Name="MyDrawerRight"
115+
Grid.Row="1"
116+
Grid.Column="1"
117+
Margin="2"
118+
Position="Right">
119+
<wd:Drawer.Header>
120+
<Grid Width="100">
121+
<StackPanel HorizontalAlignment="Center">
122+
<TextBlock
123+
HorizontalAlignment="Center"
124+
FontSize="18"
125+
Text="Drawer" />
126+
<Button
127+
HorizontalAlignment="Center"
128+
Content="contents..."
129+
Style="{StaticResource WD.WarningDefaultButton}" />
130+
</StackPanel>
131+
</Grid>
132+
</wd:Drawer.Header>
133+
<wd:Drawer.Content>
134+
<StackPanel HorizontalAlignment="Center">
135+
<TextBlock Text="抽屉从右侧滑出,点击遮罩区关闭。" />
136+
<Button
137+
Margin="0,10"
138+
HorizontalAlignment="Center"
139+
Click="ButtonRight_Click"
140+
Content="Open"
141+
Style="{StaticResource WD.WarningPrimaryButton}" />
142+
</StackPanel>
143+
</wd:Drawer.Content>
144+
</wd:Drawer>
145+
</Grid>
146+
<controls:CodeViewer.SourceCodes>
147+
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/DrawerExample.xaml" CodeType="Xaml" />
148+
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/DrawerExample.xaml.cs" CodeType="CSharp" />
149+
</controls:CodeViewer.SourceCodes>
150+
</controls:CodeViewer>
151+
</UserControl>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Windows;
2+
using System;
3+
using System.Windows.Controls;
4+
using System.Windows.Media.Animation;
5+
using System.Windows.Media;
6+
7+
namespace WPFDevelopers.Samples.ExampleViews
8+
{
9+
/// <summary>
10+
/// DrawerExample.xaml 的交互逻辑
11+
/// </summary>
12+
public partial class DrawerExample : UserControl
13+
{
14+
public DrawerExample()
15+
{
16+
InitializeComponent();
17+
}
18+
19+
private void ButtonTop_Click(object sender, System.Windows.RoutedEventArgs e)
20+
{
21+
MyDrawerTop.IsOpen = true;
22+
}
23+
24+
private void ButtonBottom_Click(object sender, System.Windows.RoutedEventArgs e)
25+
{
26+
MyDrawerBottom.IsOpen = true;
27+
}
28+
private void ButtonLeft_Click(object sender, System.Windows.RoutedEventArgs e)
29+
{
30+
MyDrawerLeft.IsOpen = true;
31+
}
32+
private void ButtonRight_Click(object sender, System.Windows.RoutedEventArgs e)
33+
{
34+
MyDrawerRight.IsOpen = true;
35+
}
36+
}
37+
}

src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public enum MenuEnum
8585
Drap,
8686
ChartPie,
8787
Spacing,
88+
Drawer,
8889
VirtualizingWrapPanel,
8990
AcrylicBlur,
9091
TaskbarInfo

src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ void MenuItemSelection(string _menuName)
358358
case MenuEnum.Spacing:
359359
ControlPanel = new SpacingExample();
360360
break;
361+
case MenuEnum.Drawer:
362+
ControlPanel = new DrawerExample();
363+
break;
361364
case MenuEnum.VirtualizingWrapPanel:
362365
ControlPanel = new VirtualizingWrapPanel();
363366
new VirtualizingWrapPanelExample().MaskShowDialog();

src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@
173173
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\DrapView\DrapViewExample.xaml.cs">
174174
<DependentUpon>DrapViewExample.xaml</DependentUpon>
175175
</Compile>
176+
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\DrawerExample.xaml.cs">
177+
<DependentUpon>DrawerExample.xaml</DependentUpon>
178+
</Compile>
176179
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\DrawerMenu\DrawerMenuExample.xaml.cs">
177180
<SubType>Code</SubType>
178181
<DependentUpon>DrawerMenuExample.xaml</DependentUpon>
@@ -662,6 +665,10 @@
662665
<Generator>MSBuild:Compile</Generator>
663666
<SubType>Designer</SubType>
664667
</Page>
668+
<Page Include="$(MSBuildThisFileDirectory)ExampleViews\DrawerExample.xaml">
669+
<Generator>MSBuild:Compile</Generator>
670+
<SubType>Designer</SubType>
671+
</Page>
665672
<Page Include="$(MSBuildThisFileDirectory)ExampleViews\DrawerMenu\DrawerMenuExample.xaml">
666673
<Generator>MSBuild:Compile</Generator>
667674
<SubType>Designer</SubType>

src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\WaterfallPanelExample.xaml.cs" Link="ExampleViews\WaterfallPanelExample.xaml.cs" DependentUpon="WaterfallPanelExample.xaml" />
146146
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\ChartLineExample.xaml.cs" Link="ExampleViews\ChartLineExample.xaml.cs" DependentUpon="ChartLineExample.xaml" />
147147
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\ChartPieExample.xaml.cs" Link="ExampleViews\ChartPieExample.xaml.cs" DependentUpon="ChartPieExample.xaml" />
148+
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\DrawerExample.xaml.cs" Link="ExampleViews\DrawerExample.xaml.cs" DependentUpon="DrawerExample.xaml" />
148149
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\\Loadings\StreamerLoading.cs" Link="Controls\Loadings\StreamerLoading.cs"/>
149150
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\SpacingExample.xaml.cs" Link="ExampleViews\SpacingExample.xaml.cs" DependentUpon="SpacingExample.xaml" />
150151
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\NotifyIconExample.xaml.cs" Link="ExampleViews\NotifyIconExample.xaml.cs" DependentUpon="NotifyIconExample.xaml" />
@@ -495,6 +496,9 @@
495496
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\ChartPieExample.xaml">
496497
<Link>ExampleViews\ChartPieExample.xaml</Link>
497498
</Resource>
499+
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\DrawerExample.xaml">
500+
<Link>ExampleViews\DrawerExample.xaml</Link>
501+
</Resource>
498502
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\Loadings\StreamerLoading.xaml">
499503
<Link>Controls\Loadings\StreamerLoading.xaml</Link>
500504
</Resource>

0 commit comments

Comments
 (0)