示例#1
0
        private void AddMainMenuButton(Page page)
        {
            if (page.BottomAppBar != null)
            {
                Template template = (Template)rootFrame.Content;

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