internal Platform(Microsoft.UI.Xaml.Window page) { if (page == null) { throw new ArgumentNullException(nameof(page)); } _page = page; var current = Microsoft.UI.Xaml.Application.Current; if (!current.Resources.ContainsKey("RootContainerStyle")) { Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(Forms.GetTabletResources()); } if (!current.Resources.ContainsKey(ShellRenderer.ShellStyle)) { var myResourceDictionary = new Microsoft.UI.Xaml.ResourceDictionary(); myResourceDictionary.Source = new Uri("ms-appx:///Microsoft.Maui.Controls.Compatibility/WinUI/Shell/ShellStyles.xbf"); Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary); } _container = new Canvas { Style = (Microsoft.UI.Xaml.Style)current.Resources["RootContainerStyle"] }; _page.Content = _container; _container.SizeChanged += OnRendererSizeChanged; MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) => { Microsoft.UI.Xaml.Controls.ProgressBar indicator = GetBusyIndicator(); indicator.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed; }); _toolbarTracker.CollectionChanged += OnToolbarItemsChanged; UpdateBounds(); InitializeStatusBar(); if (!NativeVersion.IsDesktop) { SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; } // TODO WINUI: This event is only available on UWP // Microsoft.UI.Xaml.Application.Current.Resuming += OnResumingAsync; }
Microsoft.UI.Xaml.Controls.ProgressBar GetBusyIndicator() { if (_busyIndicator == null) { _busyIndicator = new Microsoft.UI.Xaml.Controls.ProgressBar { IsIndeterminate = true, Visibility = Visibility.Collapsed, VerticalAlignment = VerticalAlignment.Top }; Canvas.SetZIndex(_busyIndicator, 1); _container.Children.Add(_busyIndicator); } return(_busyIndicator); }
//internal static Platform Current //{ // get // { // var frame = UI.Xaml.Window.Current?.Content as Microsoft.UI.Xaml.Controls.Frame; // var wbp = frame?.Content as WindowsBasePage; // return wbp?.Platform; // } //} internal Platform(Microsoft.UI.Xaml.Window page) { if (page == null) { throw new ArgumentNullException(nameof(page)); } _page = page; var current = Microsoft.UI.Xaml.Application.Current; _container = new Canvas { Style = (Microsoft.UI.Xaml.Style)current.Resources["RootContainerStyle"] }; _page.Content = _container; _container.SizeChanged += OnRendererSizeChanged; MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) => { Microsoft.UI.Xaml.Controls.ProgressBar indicator = GetBusyIndicator(); indicator.Visibility = enabled ? WVisibility.Visible : WVisibility.Collapsed; }); _toolbarTracker.CollectionChanged += OnToolbarItemsChanged; UpdateBounds(); InitializeStatusBar(); // https://docs.microsoft.com/en-us/windows/winui/api/microsoft.ui.xaml.window.current?view=winui-3.0 // The currently activated window for UWP apps. Null for Desktop apps. if (Microsoft.UI.Xaml.Window.Current != null) { SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; } // TODO WINUI: This event is only available on UWP // Microsoft.UI.Xaml.Application.Current.Resuming += OnResumingAsync; }