Skip to content

Commit 5d319eb

Browse files
authored
Merge pull request #514 from ButchersBoy/extra-drawer-content
Finish drawer right/top/bottom (finally!). Fixes #513
2 parents 3b1b8df + 82541cd commit 5d319eb

File tree

10 files changed

+922
-90
lines changed

10 files changed

+922
-90
lines changed

MainDemo.Wpf/Drawers.xaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<UserControl x:Class="MaterialDesignDemo.Drawers"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MaterialDesignDemo"
7+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
8+
mc:Ignorable="d"
9+
d:DesignHeight="300" d:DesignWidth="300">
10+
<materialDesign:DrawerHost Margin="64" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="2" BorderBrush="{DynamicResource MaterialDesignDivider}">
11+
<materialDesign:DrawerHost.LeftDrawerContent>
12+
<StackPanel Margin="16">
13+
<TextBlock Margin="4" HorizontalAlignment="Center">LEFT FIELD</TextBlock>
14+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
15+
CommandParameter="{x:Static Dock.Left}"
16+
Margin="4" HorizontalAlignment="Center"
17+
Style="{DynamicResource MaterialDesignFlatButton}">
18+
CLOSE THIS
19+
</Button>
20+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
21+
Margin="4" HorizontalAlignment="Center"
22+
Style="{DynamicResource MaterialDesignFlatButton}">
23+
CLOSE ALL
24+
</Button>
25+
</StackPanel>
26+
</materialDesign:DrawerHost.LeftDrawerContent>
27+
<materialDesign:DrawerHost.TopDrawerContent>
28+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
29+
<TextBlock Margin="4" VerticalAlignment="Center">TOP BANANA</TextBlock>
30+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
31+
Style="{DynamicResource MaterialDesignFlatButton}"
32+
Margin="4" VerticalAlignment="Center">
33+
CLOSE ALL
34+
</Button>
35+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
36+
CommandParameter="{x:Static Dock.Top}"
37+
Style="{DynamicResource MaterialDesignFlatButton}"
38+
Margin="4" VerticalAlignment="Center">
39+
CLOSE THIS
40+
</Button>
41+
</StackPanel>
42+
</materialDesign:DrawerHost.TopDrawerContent>
43+
<materialDesign:DrawerHost.RightDrawerContent>
44+
<StackPanel Margin="16">
45+
<TextBlock Margin="4" HorizontalAlignment="Center">THE RIGHT STUFF</TextBlock>
46+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
47+
CommandParameter="{x:Static Dock.Right}"
48+
Margin="4" HorizontalAlignment="Center"
49+
Style="{DynamicResource MaterialDesignFlatButton}">
50+
CLOSE THIS
51+
</Button>
52+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
53+
Margin="4" HorizontalAlignment="Center"
54+
Style="{DynamicResource MaterialDesignFlatButton}">
55+
CLOSE ALL
56+
</Button>
57+
</StackPanel>
58+
</materialDesign:DrawerHost.RightDrawerContent>
59+
<materialDesign:DrawerHost.BottomDrawerContent>
60+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
61+
<TextBlock Margin="4" VerticalAlignment="Center">BOTTOM BRACKET</TextBlock>
62+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
63+
Style="{DynamicResource MaterialDesignFlatButton}"
64+
Margin="4" VerticalAlignment="Center">
65+
CLOSE ALL
66+
</Button>
67+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
68+
CommandParameter="{x:Static Dock.Bottom}"
69+
Style="{DynamicResource MaterialDesignFlatButton}"
70+
Margin="4" VerticalAlignment="Center">
71+
CLOSE THIS
72+
</Button>
73+
</StackPanel>
74+
</materialDesign:DrawerHost.BottomDrawerContent>
75+
<Grid MinWidth="480" MinHeight="480">
76+
<Grid VerticalAlignment="Center" HorizontalAlignment="Center">
77+
<Grid.RowDefinitions>
78+
<RowDefinition />
79+
<RowDefinition />
80+
<RowDefinition />
81+
</Grid.RowDefinitions>
82+
<Grid.ColumnDefinitions>
83+
<ColumnDefinition />
84+
<ColumnDefinition />
85+
<ColumnDefinition />
86+
</Grid.ColumnDefinitions>
87+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
88+
CommandParameter="{x:Static Dock.Left}"
89+
Grid.Row="1" Grid.Column="0" Margin="4">
90+
<materialDesign:PackIcon Kind="ArrowLeft" />
91+
</Button>
92+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
93+
CommandParameter="{x:Static Dock.Top}"
94+
Grid.Row="0" Grid.Column="1" Margin="4">
95+
<materialDesign:PackIcon Kind="ArrowUp" />
96+
</Button>
97+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
98+
CommandParameter="{x:Static Dock.Right}"
99+
Grid.Row="1" Grid.Column="2" Margin="4">
100+
<materialDesign:PackIcon Kind="ArrowRight" />
101+
</Button>
102+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
103+
CommandParameter="{x:Static Dock.Bottom}"
104+
Grid.Row="2" Grid.Column="1" Margin="4">
105+
<materialDesign:PackIcon Kind="ArrowDown" />
106+
</Button>
107+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
108+
Grid.Row="1" Grid.Column="1" Margin="4"
109+
Style="{DynamicResource MaterialDesignRaisedAccentButton}">
110+
<materialDesign:PackIcon Kind="ArrowAll" />
111+
</Button>
112+
</Grid>
113+
</Grid>
114+
</materialDesign:DrawerHost>
115+
</UserControl>

MainDemo.Wpf/Drawers.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MaterialDesignDemo
17+
{
18+
/// <summary>
19+
/// Interaction logic for Drawers.xaml
20+
/// </summary>
21+
public partial class Drawers : UserControl
22+
{
23+
public Drawers()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

MainDemo.Wpf/MainWindow.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
</wpfExample:Dialogs>
174174
</domain:DemoItem.Content>
175175
</domain:DemoItem>
176+
<domain:DemoItem Name="Drawers">
177+
<domain:DemoItem.Content>
178+
<materialDesignDemo:Drawers />
179+
</domain:DemoItem.Content>
180+
</domain:DemoItem>
176181
<domain:DemoItem Name="Transitions">
177182
<domain:DemoItem.Content>
178183
<materialDesignDemo:Transitions />

MainDemo.Wpf/MaterialDesignDemo.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<Compile Include="Domain\SimpleDateValidationRule.cs" />
112112
<Compile Include="Domain\TextFieldsViewModel.cs" />
113113
<Compile Include="Domain\TreesViewModel.cs" />
114+
<Compile Include="Drawers.xaml.cs">
115+
<DependentUpon>Drawers.xaml</DependentUpon>
116+
</Compile>
114117
<Compile Include="Expander.xaml.cs">
115118
<DependentUpon>Expander.xaml</DependentUpon>
116119
</Compile>
@@ -213,6 +216,10 @@
213216
<SubType>Designer</SubType>
214217
<Generator>MSBuild:Compile</Generator>
215218
</Page>
219+
<Page Include="Drawers.xaml">
220+
<SubType>Designer</SubType>
221+
<Generator>MSBuild:Compile</Generator>
222+
</Page>
216223
<Page Include="Expander.xaml">
217224
<SubType>Designer</SubType>
218225
<Generator>MSBuild:Compile</Generator>

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 105 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<UserControl.Resources>
1313
<ResourceDictionary>
1414
<ResourceDictionary.MergedDictionaries>
15+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
1516
<!--
1617
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
1718
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
@@ -28,22 +29,109 @@
2829
</ResourceDictionary>
2930
</UserControl.Resources>
3031

31-
<materialDesign:DialogHost Identifier="RootDialog">
32-
<ScrollViewer VerticalScrollBarVisibility="Auto" Background="White">
33-
<Grid>
34-
<TextBox x:Name="loginText"
35-
materialDesign:HintAssist.FloatingScale=".56"
36-
materialDesign:HintAssist.FloatingOffset="1,-42"
37-
Style="{StaticResource MaterialDesignFloatingHintTextBox}" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" Margin="0,350,0,0" materialDesign:HintAssist.IsFloating="True" HorizontalAlignment="Center" VerticalAlignment="Top" Width="400" FontSize="36" Height="100" Background="White" Padding="6,0,0,2">
38-
<materialDesign:HintAssist.Hint>
39-
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
40-
<materialDesign:PackIcon Kind="Account" Width="50" Height="50" />
41-
<TextBlock Padding="5,0,0,0">Enter login</TextBlock>
42-
</StackPanel>
43-
</materialDesign:HintAssist.Hint>
44-
</TextBox>
45-
</Grid>
46-
</ScrollViewer>
47-
</materialDesign:DialogHost>
32+
<materialDesign:DrawerHost>
33+
<materialDesign:DrawerHost.LeftDrawerContent>
34+
<StackPanel Margin="16">
35+
<TextBlock Margin="4" HorizontalAlignment="Center">LEFT FIELD</TextBlock>
36+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
37+
CommandParameter="{x:Static Dock.Left}"
38+
Margin="4" HorizontalAlignment="Center"
39+
Style="{DynamicResource MaterialDesignFlatButton}">
40+
CLOSE THIS
41+
</Button>
42+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
43+
Margin="4" HorizontalAlignment="Center"
44+
Style="{DynamicResource MaterialDesignFlatButton}">
45+
CLOSE ALL
46+
</Button>
47+
</StackPanel>
48+
</materialDesign:DrawerHost.LeftDrawerContent>
49+
<materialDesign:DrawerHost.TopDrawerContent>
50+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
51+
<TextBlock Margin="4" VerticalAlignment="Center">TOP BANANA</TextBlock>
52+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
53+
Style="{DynamicResource MaterialDesignFlatButton}"
54+
Margin="4" VerticalAlignment="Center">
55+
CLOSE ALL
56+
</Button>
57+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
58+
CommandParameter="{x:Static Dock.Top}"
59+
Style="{DynamicResource MaterialDesignFlatButton}"
60+
Margin="4" VerticalAlignment="Center">
61+
CLOSE THIS
62+
</Button>
63+
</StackPanel>
64+
</materialDesign:DrawerHost.TopDrawerContent>
65+
<materialDesign:DrawerHost.RightDrawerContent>
66+
<StackPanel Margin="16">
67+
<TextBlock Margin="4" HorizontalAlignment="Center">THE RIGHT STUFF</TextBlock>
68+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
69+
CommandParameter="{x:Static Dock.Right}"
70+
Margin="4" HorizontalAlignment="Center"
71+
Style="{DynamicResource MaterialDesignFlatButton}">
72+
CLOSE THIS
73+
</Button>
74+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
75+
Margin="4" HorizontalAlignment="Center"
76+
Style="{DynamicResource MaterialDesignFlatButton}">
77+
CLOSE ALL
78+
</Button>
79+
</StackPanel>
80+
</materialDesign:DrawerHost.RightDrawerContent>
81+
<materialDesign:DrawerHost.BottomDrawerContent>
82+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
83+
<TextBlock Margin="4" VerticalAlignment="Center">BOTTOM BRACKET</TextBlock>
84+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
85+
Style="{DynamicResource MaterialDesignFlatButton}"
86+
Margin="4" VerticalAlignment="Center">
87+
CLOSE ALL
88+
</Button>
89+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
90+
CommandParameter="{x:Static Dock.Bottom}"
91+
Style="{DynamicResource MaterialDesignFlatButton}"
92+
Margin="4" VerticalAlignment="Center">
93+
CLOSE THIS
94+
</Button>
95+
</StackPanel>
96+
</materialDesign:DrawerHost.BottomDrawerContent>
97+
98+
<Grid VerticalAlignment="Center" HorizontalAlignment="Center">
99+
<Grid.RowDefinitions>
100+
<RowDefinition />
101+
<RowDefinition />
102+
<RowDefinition />
103+
</Grid.RowDefinitions>
104+
<Grid.ColumnDefinitions>
105+
<ColumnDefinition />
106+
<ColumnDefinition />
107+
<ColumnDefinition />
108+
</Grid.ColumnDefinitions>
109+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
110+
CommandParameter="{x:Static Dock.Left}"
111+
Grid.Row="1" Grid.Column="0" Margin="4">
112+
<materialDesign:PackIcon Kind="ArrowLeft" />
113+
</Button>
114+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
115+
CommandParameter="{x:Static Dock.Top}"
116+
Grid.Row="0" Grid.Column="1" Margin="4">
117+
<materialDesign:PackIcon Kind="ArrowUp" />
118+
</Button>
119+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
120+
CommandParameter="{x:Static Dock.Right}"
121+
Grid.Row="1" Grid.Column="2" Margin="4">
122+
<materialDesign:PackIcon Kind="ArrowRight" />
123+
</Button>
124+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
125+
CommandParameter="{x:Static Dock.Bottom}"
126+
Grid.Row="2" Grid.Column="1" Margin="4">
127+
<materialDesign:PackIcon Kind="ArrowDown" />
128+
</Button>
129+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
130+
Grid.Row="1" Grid.Column="1" Margin="4"
131+
Style="{DynamicResource MaterialDesignRaisedAccentButton}">
132+
<materialDesign:PackIcon Kind="ArrowAll" />
133+
</Button>
134+
</Grid>
135+
</materialDesign:DrawerHost>
48136

49137
</UserControl>

MaterialDesignThemes.Wpf/Converters/DrawerOffsetConverter.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Linq;
55
using System.Text;
66
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
79
using System.Windows.Data;
810

911
namespace MaterialDesignThemes.Wpf.Converters
@@ -14,7 +16,20 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1416
{
1517
var d = value as double? ?? 0;
1618
if (double.IsInfinity(d) || double.IsNaN(d)) d = 0;
17-
return 0 - d;
19+
20+
var dock = (parameter is Dock) ? (Dock)parameter : Dock.Left;
21+
switch (dock)
22+
{
23+
case Dock.Top:
24+
return new Thickness(0, 0 - d, 0, 0);
25+
case Dock.Bottom:
26+
return new Thickness(0, 0, 0, 0 - d);
27+
case Dock.Right:
28+
return new Thickness(0, 0, 0 - d, 0);
29+
case Dock.Left:
30+
default:
31+
return new Thickness(0 - d, 0, 0, 0);
32+
}
1833
}
1934

2035
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

0 commit comments

Comments
 (0)