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; } }
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; } } }