Skip to content

Commit 092b93a

Browse files
committed
Merge remote-tracking branch 'refs/remotes/ButchersBoy/master' into FixMenuItem
2 parents ee0e75d + 904ff09 commit 092b93a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

MainDemo.Wpf/Home.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
<Image Source="Resources/ms-icon-310x310.png" Stretch="Uniform" Width="100" Height="100" />
2020
<StackPanel Grid.Column="1" Margin="24 0 0 0">
2121
<TextBlock FontSize="32" TextWrapping="Wrap">Welcome to Material Design In XAML Toolkit</TextBlock>
22-
<TextBlock Margin="0 8 0 0" TextWrapping="Wrap" Foreground="{DynamicResource MaterialDesignBodyLight}">Use the left-hand menu to checkout the various controls &amp; themes.</TextBlock>
22+
<TextBlock Margin="0 8 0 10" TextWrapping="Wrap" Foreground="{DynamicResource MaterialDesignBodyLight}">Click EXPLORE to checkout the various controls &amp; themes.</TextBlock>
23+
<Button Command="{x:Static wpf:DrawerHost.OpenDrawerCommand}">EXPLORE</Button>
2324
</StackPanel>
2425
</Grid>
2526
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"

MaterialDesignThemes.Wpf/DrawerHost.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,22 @@ public class DrawerHost : ContentControl
2222

2323
public const string TemplateContentCoverPartName = "PART_ContentCover";
2424

25+
public static RoutedCommand OpenDrawerCommand = new RoutedCommand();
26+
public static RoutedCommand CloseDrawerCommand = new RoutedCommand();
27+
2528
private FrameworkElement _templateContentCoverElement;
2629

2730
static DrawerHost()
2831
{
2932
DefaultStyleKeyProperty.OverrideMetadata(typeof(DrawerHost), new FrameworkPropertyMetadata(typeof(DrawerHost)));
3033
}
3134

35+
public DrawerHost()
36+
{
37+
CommandBindings.Add(new CommandBinding(OpenDrawerCommand, OpenDrawerHandler));
38+
CommandBindings.Add(new CommandBinding(CloseDrawerCommand, CloseDrawerHandler));
39+
}
40+
3241
public static readonly DependencyProperty LeftDrawerContentProperty = DependencyProperty.Register(
3342
"LeftDrawerContent", typeof (object), typeof (DrawerHost), new PropertyMetadata(default(object)));
3443

@@ -119,5 +128,22 @@ private static void IsLeftDrawerOpenPropertyChangedCallback(DependencyObject dep
119128
((DrawerHost)dependencyObject).UpdateVisualStates(true);
120129
}
121130

131+
private void CloseDrawerHandler(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
132+
{
133+
if (executedRoutedEventArgs.Handled) return;
134+
135+
SetCurrentValue(IsLeftDrawerOpenProperty, false);
136+
137+
executedRoutedEventArgs.Handled = true;
138+
}
139+
140+
private void OpenDrawerHandler(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
141+
{
142+
if (executedRoutedEventArgs.Handled) return;
143+
144+
SetCurrentValue(IsLeftDrawerOpenProperty, true);
145+
146+
executedRoutedEventArgs.Handled = true;
147+
}
122148
}
123149
}

0 commit comments

Comments
 (0)