MonoMobile.Views.ViewCreator.Create C# (CSharp) Méthode

Create() public static méthode

public static Create ( Type viewType, object dataContext ) : UIView
viewType System.Type
dataContext object
Résultat UIView
		public static UIView Create(Type viewType, object dataContext)
		{
			var view = Activator.CreateInstance(viewType) as UIView; 
				
			var initalizable = view as IInitializable;
			if (initalizable != null)
			{
				initalizable.Initialize();
			}
			
			var dc = view as IDataContext<object>;
			if (dc != null)
			{
				dc.DataContext = dataContext;
			}

			var activation = view as IActivation;
			if (activation != null)
			{
				activation.Activated();
			}

			return view;
		}
	}

Usage Example

        public virtual void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath)
        {
            if (DataContext.Value == null)
            {
                DataContext.Value = Activator.CreateInstance(DataContext.Member.GetMemberType());
            }

//			if (typeof(Enum).IsAssignableFrom(DataContext.Type))
//			{
//				var parser = new ViewParser();
//
//				var source = parser.ParseList(null, DataContext.Source, DataContext.Member, null);
//			}

            if (DataContext.Value != null)
            {
                var view = DataContext.Value;
                if (NavigateToViewType != null && !view.GetType().Equals(NavigateToViewType))
                {
                    view = ViewCreator.Create(NavigateToViewType, DataContext.Value);
                }

                var dvc = new DialogViewController(Caption, view, controller.Theme, true)
                {
                    Autorotate = true
                };
                var nav = controller.ParentViewController as UINavigationController;

                if (IsModal)
                {
                    dvc.ModalTransitionStyle = TransitionStyle;

                    var navController = new NavigationController()
                    {
                        ViewControllers = new UIViewController[] { dvc }
                    };

                    nav.PresentModalViewController(navController, true);
                }
                else
                {
                    nav.PushViewController(dvc, true);
                }
            }
        }
All Usage Examples Of MonoMobile.Views.ViewCreator::Create
ViewCreator