Beispiel #1
0
        /// <summary>
        /// Creates a view with the given tag and class name.
        /// </summary>
        /// <param name="themedContext">The context.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="className">The class name.</param>
        /// <param name="initialProps">The initial props.</param>
        public void CreateView(ThemedReactContext themedContext, int tag, string className, JObject initialProps)
        {
            AssertOnCorrectDispatcher();
            using (Tracer.Trace(Tracer.TRACE_TAG_REACT_VIEW, "NativeViewHierarcyManager.CreateView")
                   .With("tag", tag)
                   .With("className", className)
                   .Start())
            {
                var viewManager = _viewManagers.Get(className);
                var view        = viewManager.CreateView(themedContext);
                _tagsToViews.Add(tag, view);
                _tagsToViewManagers.Add(tag, viewManager);

                ViewExtensions.SetTag(view, tag);
                ViewExtensions.SetReactContext(view, themedContext);

#if WINDOWS_UWP
                if (view is UIElement element)
                {
                    AccessibilityHelper.OnViewInstanceCreated(element);
                }
#endif

                if (initialProps != null)
                {
                    viewManager.UpdateProps(view, initialProps);
                }
            }
        }
        /// <summary>
        /// Creates a view and installs event emitters on it.
        /// </summary>
        /// <param name="reactContext">The context.</param>
        /// <returns>The view.</returns>
        public TFrameworkElement CreateView(ThemedReactContext reactContext)
        {
            var view = CreateViewInstance(reactContext);

#if WINDOWS_UWP
            AccessibilityHelper.OnViewInstanceCreated(view);
#endif
            AddEventEmitters(reactContext, view);
            // TODO: enable touch intercepting view parents
            return(view);
        }