Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/ButchersBoy/master' into F…
Browse files Browse the repository at this point in the history
…ixMenuItem
  • Loading branch information
l1pton17 committed Oct 10, 2015
2 parents ee0e75d + 904ff09 commit 092b93a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion MainDemo.Wpf/Home.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<Image Source="Resources/ms-icon-310x310.png" Stretch="Uniform" Width="100" Height="100" />
<StackPanel Grid.Column="1" Margin="24 0 0 0">
<TextBlock FontSize="32" TextWrapping="Wrap">Welcome to Material Design In XAML Toolkit</TextBlock>
<TextBlock Margin="0 8 0 0" TextWrapping="Wrap" Foreground="{DynamicResource MaterialDesignBodyLight}">Use the left-hand menu to checkout the various controls &amp; themes.</TextBlock>
<TextBlock Margin="0 8 0 10" TextWrapping="Wrap" Foreground="{DynamicResource MaterialDesignBodyLight}">Click EXPLORE to checkout the various controls &amp; themes.</TextBlock>
<Button Command="{x:Static wpf:DrawerHost.OpenDrawerCommand}">EXPLORE</Button>
</StackPanel>
</Grid>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"
Expand Down
26 changes: 26 additions & 0 deletions MaterialDesignThemes.Wpf/DrawerHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ public class DrawerHost : ContentControl

public const string TemplateContentCoverPartName = "PART_ContentCover";

public static RoutedCommand OpenDrawerCommand = new RoutedCommand();
public static RoutedCommand CloseDrawerCommand = new RoutedCommand();

private FrameworkElement _templateContentCoverElement;

static DrawerHost()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(DrawerHost), new FrameworkPropertyMetadata(typeof(DrawerHost)));
}

public DrawerHost()
{
CommandBindings.Add(new CommandBinding(OpenDrawerCommand, OpenDrawerHandler));
CommandBindings.Add(new CommandBinding(CloseDrawerCommand, CloseDrawerHandler));
}

public static readonly DependencyProperty LeftDrawerContentProperty = DependencyProperty.Register(
"LeftDrawerContent", typeof (object), typeof (DrawerHost), new PropertyMetadata(default(object)));

Expand Down Expand Up @@ -119,5 +128,22 @@ private static void IsLeftDrawerOpenPropertyChangedCallback(DependencyObject dep
((DrawerHost)dependencyObject).UpdateVisualStates(true);
}

private void CloseDrawerHandler(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
{
if (executedRoutedEventArgs.Handled) return;

SetCurrentValue(IsLeftDrawerOpenProperty, false);

executedRoutedEventArgs.Handled = true;
}

private void OpenDrawerHandler(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
{
if (executedRoutedEventArgs.Handled) return;

SetCurrentValue(IsLeftDrawerOpenProperty, true);

executedRoutedEventArgs.Handled = true;
}
}
}

0 comments on commit 092b93a

Please sign in to comment.