public T CreateContentModel <T>(Action <T> initialisedCallback, XViewModel createdBy = null) where T : XViewModel { var rootModel = this; rootModel.KnownTypes.Add(typeof(T)); var obj = Container.Resolve <T>(); if (Dispatcher == null) { throw new Exception("Dispatcher is null, do soemthing like this in RootViewModel ctor Dispatcher = (a) => Deployment.Current.Dispatcher.BeginInvoke(a);"); } obj.Dispatcher = Dispatcher; obj.ParentModel = this; obj.ParentViewModel = createdBy; if (createdBy != null) { obj.Tag = createdBy.Tag; } obj.LoadStatusService = _loadStatusService; obj.OrientationService = _orientationService; obj.LocalisationService = _localisationService; obj.Container = Container; if (initialisedCallback != null) { initialisedCallback(obj); } rootModel.AllViewModels.Add(obj); obj.OnInitialise(); return(obj); }
public T CreateContentModel <T>(XViewModel createdBy = null) where T : XViewModel { return(CreateContentModel <T>(null, createdBy)); }