Пример #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>
 /// Gets the <see cref="ThemedReactContext"/> associated with the view
 /// instance.
 /// </summary>
 /// <param name="view">The view instance.</param>
 /// <returns>The context.</returns>
 /// <exception cref="InvalidOperationException">
 /// Thrown if context is not available for the view.
 /// </exception>
 public static ThemedReactContext GetReactContext(this DependencyObject view)
 {
     return(ViewExtensions.GetReactContext(view));
 }
 /// <summary>
 /// Checks if a React tag is available for the view instance.
 /// </summary>
 /// <param name="view">The view instance.</param>
 /// <returns>
 /// <code>true</code> if the view has a tag, <code>false</code> otherwise.
 /// </returns>
 public static bool HasTag(this DependencyObject view)
 {
     return(ViewExtensions.HasTag(view));
 }
 /// <summary>
 /// Get the React tag for the view instance.
 /// </summary>
 /// <param name="view">The view instance.</param>
 /// <returns>The React tag.</returns>
 /// <exception cref="InvalidOperationException">
 /// Thrown if tag is not available for the view.
 /// </exception>
 public static int GetTag(this DependencyObject view)
 {
     return(ViewExtensions.GetTag(view));
 }
 /// <summary>
 /// Gets the implementation of IReactCompoundView associated with the view.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <returns>
 /// The implementation of IReactCompoundView associated with the view. Defaults to
 /// an instance of ReactDefaultCompoundView when no other implementation has been
 /// provided.
 /// </returns>
 public static IReactCompoundView GetReactCompoundView(this DependencyObject view)
 {
     return(ViewExtensions.GetReactCompoundView(view));
 }
 /// <summary>
 /// Associates an implementation of IReactCompoundView with the view.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="compoundView">The implementation of IReactCompoundView.</param>
 public static void SetReactCompoundView(this DependencyObject view, IReactCompoundView compoundView)
 {
     ViewExtensions.SetReactCompoundView(view, compoundView);
 }
 /// <summary>
 /// Gets the pointer events for the view.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <returns>The pointer events.</returns>
 public static PointerEvents GetPointerEvents(this DependencyObject view)
 {
     return(ViewExtensions.GetPointerEvents(view));
 }
 /// <summary>
 /// Sets the pointer events for the view.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="pointerEvents">The pointer events.</param>
 public static void SetPointerEvents(this DependencyObject view, PointerEvents pointerEvents)
 {
     ViewExtensions.SetPointerEvents(view, pointerEvents);
 }