Beispiel #1
0
        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;
        }
Beispiel #2
0
        public MauiWinUIWindow()
        {
            Activated         += OnActivated;
            Closed            += OnClosed;
            VisibilityChanged += OnVisibilityChanged;

            if (!Application.Current.Resources.ContainsKey("MauiRootContainerStyle"))
            {
                var myResourceDictionary = new Microsoft.UI.Xaml.ResourceDictionary();
                myResourceDictionary.Source = new Uri("ms-appx:///Microsoft.Maui/Platform/Windows/Styles/MauiTextBoxStyle.xbf");
                Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
            }
        }