Beispiel #1
0
        public void SetElement(VisualElement element)
        {
            if (Element != null)
            {
                throw new NotSupportedException("Reuse of the Shell Renderer is not supported");
            }
            Element = element;
            OnElementSet((Shell)Element);

            ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(null, Element));
            Mapper.UpdateProperties(this, Element);
        }
Beispiel #2
0
        public virtual void SetVirtualView(IElement view)
        {
            _ = view ?? throw new ArgumentNullException(nameof(view));

            if (VirtualView == view)
            {
                return;
            }

            var oldVirtualView = VirtualView;

            if (oldVirtualView?.Handler != null)
            {
                oldVirtualView.Handler = null;
            }

            bool setupNativeView = oldVirtualView == null;

            VirtualView = view;
            NativeView ??= CreateNativeElement();

            if (VirtualView.Handler != this)
            {
                VirtualView.Handler = this;
            }

            if (setupNativeView)
            {
                ConnectHandler(NativeView);
            }

            _mapper = _defaultMapper;

            if (VirtualView is IPropertyMapperView imv)
            {
                var map = imv.GetPropertyMapperOverrides();
                if (map is not null)
                {
                    map.Chained = new[] { _defaultMapper };
                    _mapper     = map;
                }
            }

            _mapper.UpdateProperties(this, VirtualView);
        }