Beispiel #1
0
        public UIElement(string htmlTag = "div", bool isSvg = false)
        {
            _gcHandle           = GCHandle.Alloc(this, GCHandleType.Weak);
            _isFrameworkElement = this is FrameworkElement;
            HtmlTag             = htmlTag;
            HtmlTagIsSvg        = isSvg;

            var type = GetType();

            Handle = GCHandle.ToIntPtr(_gcHandle);
            HtmlId = Handle;


            Uno.UI.Xaml.WindowManagerInterop.CreateContent(
                htmlId: HtmlId,
                htmlTag: HtmlTag,
                handle: Handle,
                fullName: type.FullName,
                htmlTagIsSvg: HtmlTagIsSvg,
                isFrameworkElement: this is FrameworkElement,
                isFocusable: false,
                classes: ClassNames.GetForType(type)
                );

            InitializePointers();
            UpdateHitTest();

            FocusManager.Track(this);
        }
Beispiel #2
0
        public UIElement(string htmlTag = "div", bool isSvg = false)
        {
            _gcHandle    = GCHandle.Alloc(this, GCHandleType.Weak);
            HtmlTag      = htmlTag;
            HtmlTagIsSvg = isSvg;

            var type = GetType();

            Handle = GCHandle.ToIntPtr(_gcHandle);
            HtmlId = type.Name + "-" + Handle;

            var          isSvgStr = HtmlTagIsSvg ? "true" : "false";
            var          isFrameworkElementStr = this is FrameworkElement ? "true" : "false";
            const string isFocusable           = "false";   // by default all control are not focusable, it has to be change latter by the control itself
            var          classes = ClassNames.GetForType(type);

            WebAssemblyRuntime.InvokeJS(
                "Uno.UI.WindowManager.current.createContent({" +
                "id:\"" + HtmlId + "\"," +
                "tagName:\"" + HtmlTag + "\", " +
                "handle:" + Handle + ", " +
                "type:\"" + type.FullName + "\", " +
                "isSvg:" + isSvgStr + ", " +
                "isFrameworkElement:" + isFrameworkElementStr + ", " +
                "isFocusable:" + isFocusable + ", " +
                "classes:[" + classes + "]" +
                "});");

            UpdateHitTest();

            FocusManager.Track(this);
        }