public MainView() { this.InitializeComponent(); var channelService = Locator.Current.GetService <IChannelService>(); var discoveryService = Locator.Current.GetService <IDiscoveryService>(); var blobCache = BlobCache.UserAccount; ViewModel = new MainViewModel(discoveryService, channelService, blobCache); StateViewModel = new ConnectionStateViewModel(channelService); // The settings var settingsViewModel = new SettingsViewModel(ViewModel, this, blobCache); Locator.CurrentMutable.RegisterLazySingleton(() => settingsViewModel, typeof(IRoutableViewModel), "Settings"); Window.Current.SetTitleBar(AppTitleBar); //CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s); // remove the solid-colored backgrounds behind the caption controls and system back button // This is done when the app is loaded since before that the actual theme that is used is not "determined" yet Loaded += (sender, e) => UpdateTitleBar(true); NavigationViewControl.RegisterPropertyChangedCallback(Muxc.NavigationView.PaneDisplayModeProperty, new DependencyPropertyChangedCallback(OnPaneDisplayModeChanged)); ViewModel.NavigateTo.Execute("Connection").Subscribe(); }
protected override void OnContentChanged(object oldContent, object newContent) { base.OnContentChanged(oldContent, newContent); if (newContent is MauiNavigationView mnv) { NavigationViewControl = mnv; NavigationViewControl.DisplayModeChanged += OnNavigationViewControlDisplayModeChanged; NavigationViewControl.BackRequested += OnNavigationViewBackRequested; NavigationViewControl.RegisterPropertyChangedCallback(NavigationView.IsBackButtonVisibleProperty, AppBarNavigationIconsChanged); NavigationViewControl.RegisterPropertyChangedCallback(NavigationView.IsPaneToggleButtonVisibleProperty, AppBarNavigationIconsChanged); } }
private void AddNavigationMenuItems() { foreach (var group in ControlInfoDataSource.Instance.Groups.OrderBy(i => i.Title)) { var itemGroup = new NavigationViewControl() { Tag = group.UniqueId, DataContext = group }; //var hyperLink = new HyperlinkButton() { Content = group.Title }; this.NavigationViewControl.Children.Add(itemGroup); //var itemGroup = new Microsoft.UI.Xaml.Controls.NavigationViewItem() { Content = group.Title, Tag = group.UniqueId, DataContext = group, Icon = GetIcon(group.ImagePath) }; //AutomationProperties.SetName(itemGroup, group.Title); foreach (var item in group.Items) { var itemInGroup = new HyperlinkButton() { DataContext = item, Height = 28 }; itemInGroup.Click += ItemInGroup_Click; var content = new StackPanel() { Orientation = Orientation.Horizontal }; content.Children.Add(Utils.GetIcon(item.ImagePath)); content.Children.Add(new TextBlock() { Text = item.Title, VerticalAlignment = VerticalAlignment.Center }); itemInGroup.Content = content; //var itemInGroup = new Microsoft.UI.Xaml.Controls.NavigationViewItem() { Content = item.Title, Tag = item.UniqueId, DataContext = item, Icon = GetIcon(item.ImagePath) }; itemGroup.Items.Children.Add(itemInGroup); //AutomationProperties.SetName(itemInGroup, item.Title); } } }
public NavigationViewControlProxy(UserControl navigationViewControl) { this.navigationViewControl = navigationViewControl as NavigationViewControl; }