Beispiel #1
0
        private void InternalSetContent(UIElement content)
        {
            if (_window == null)
            {
                _rootBorder       = new Border();
                _rootScrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                    VerticalScrollMode            = ScrollMode.Disabled,
                    HorizontalScrollMode          = ScrollMode.Disabled,
                    Content = _rootBorder
                };
                _popupRoot       = new PopupRoot();
                FocusVisualLayer = new Canvas();
                _window          = new Grid()
                {
                    IsVisualTreeRoot = true,
                    Children         =
                    {
                        _rootScrollViewer,
                        _popupRoot,
                        FocusVisualLayer
                    }
                };
            }

            _rootBorder.Child = _content = content;
            if (content != null)
            {
                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_window.IsLoaded)
                {
                    UIElement.LoadingRootElement(_window);
                }

                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent({_window.HtmlId});");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_window.IsLoaded)
                {
                    UIElement.RootElementLoaded(_window);
                }
            }
            else
            {
                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent();");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && _window.IsLoaded)
                {
                    UIElement.RootElementUnloaded(_window);
                }
            }
        }
Beispiel #2
0
        private void InternalSetContent(UIElement content)
        {
            if (_rootVisual == null)
            {
                _rootBorder       = new Border();
                _rootScrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                    VerticalScrollMode            = ScrollMode.Disabled,
                    HorizontalScrollMode          = ScrollMode.Disabled,
                    Content = _rootBorder
                };
                //TODO Uno: We can set and RootScrollViewer properly in case of WASM
                CoreServices.Instance.PutVisualRoot(_rootScrollViewer);
                _rootVisual = CoreServices.Instance.MainRootVisual;

                if (_rootVisual == null)
                {
                    throw new InvalidOperationException("The root visual could not be created.");
                }
            }

            _rootBorder.Child = _content = content;
            if (content != null)
            {
                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_rootVisual.IsLoaded)
                {
                    UIElement.LoadingRootElement(_rootVisual);
                }

                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent({_rootVisual.HtmlId});");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_rootVisual.IsLoaded)
                {
                    UIElement.RootElementLoaded(_rootVisual);
                }
            }
            else
            {
                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent();");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && _rootVisual.IsLoaded)
                {
                    UIElement.RootElementUnloaded(_rootVisual);
                }
            }

            UpdateRootAttributes();
        }