Example #1
0
        public virtual void Connect(UIElement platformView)
        {
            if (_rootView.Content != null)
            {
                // We need to make sure to clear out the root view content
                // before creating the new view.
                // Otherwise the new view might try to act on the old content.
                // It might have code in the handler that retrieves this class.
                _rootView.Content = null;
            }

            NavigationView rootNavigationView;

            if (platformView is NavigationView nv)
            {
                rootNavigationView = nv;
                _rootView.Content  = platformView;
            }
            else
            {
                if (_rootView.Content is RootNavigationView navView)
                {
                    rootNavigationView = navView;
                }
                else
                {
                    rootNavigationView = new RootNavigationView();
                }

                rootNavigationView.Content = platformView;
                _rootView.Content          = rootNavigationView;
            }

            if (_disconnected)
            {
                _isActiveRootManager       = true;
                _platformWindow.Activated += OnWindowActivated;
            }

            _disconnected = false;
        }
Example #2
0
        public virtual void Connect(IView view)
        {
            bool firstConnect = _rootView.Content == null;
            var  platformView = view.ToPlatform(_mauiContext);

            NavigationView rootNavigationView;

            if (platformView is NavigationView nv)
            {
                rootNavigationView = nv;
                _rootView.Content  = platformView;
            }
            else
            {
                if (_rootView.Content is RootNavigationView navView)
                {
                    rootNavigationView = navView;
                }
                else
                {
                    rootNavigationView = new RootNavigationView();
                }

                rootNavigationView.Content = platformView;
                _rootView.Content          = rootNavigationView;
            }

            if (firstConnect)
            {
                var platformWindow = _mauiContext.GetPlatformWindow();
                platformWindow.Activated += OnWindowActivated;

                UpdateAppTitleBar(true);
                SetWindowTitle(_mauiContext.GetPlatformWindow().GetWindow()?.Title);
            }
        }