Exemplo n.º 1
0
        private void AddMainMenuButton(Page page)
        {
            if (page.BottomAppBar != null)
            {
                ITemplate template = (ITemplate)rootFrame.Content;

                MainMenuAppBarButton button = new MainMenuAppBarButton();
                button.SetBinding(
                    AppBarToggleButton.IsCheckedProperty,
                    new Binding()
                {
                    Path   = new PropertyPath(nameof(ITemplate.IsMainMenuOpened)),
                    Source = template,
                    Mode   = BindingMode.TwoWay
                }
                    );
                button.SetBinding(
                    AppBarToggleButton.IsCompactProperty,
                    new Binding()
                {
                    Path      = new PropertyPath(nameof(CommandBar.IsOpen)),
                    Source    = page.BottomAppBar,
                    Converter = (IValueConverter)Application.Current.Resources["TrueToFalseConverter"],
                    Mode      = BindingMode.OneWay
                }
                    );
                page.BottomAppBar.Content = button;
            }
        }
Exemplo n.º 2
0
 private void RemoveMainMenuButton(Page page)
 {
     if (page.BottomAppBar != null)
     {
         MainMenuAppBarButton button = page.BottomAppBar.Content as MainMenuAppBarButton;
         if (button != null)
         {
             button.Dispose();
             page.BottomAppBar.Content = null;
         }
     }
 }