private static TypeRef GetTypeRef(ViewModel mdl, IFrozenContext frozenCtx) { var tr = mdl.GetType().ToRef(frozenCtx); if (tr == null) { var mdlType = mdl.GetType(); if (mdlType.IsGenericType) { Logging.Log.ErrorFormat("Unable to resolve TypeRef of given ViewModel '{0}'. You have to manually create a generic TypeRef.", mdlType); } else { Logging.Log.ErrorFormat("Unable to resolve TypeRef of given ViewModel '{0}'. Regenerate Assembly Refs.", mdlType); } return null; } return tr; }
private static DataTemplate SelectTemplate(ViewModel mdl, ControlKind controlKind, IFrozenContext frozenCtx) { var tr = GetTypeRef(mdl, frozenCtx); if (tr == null) return null; ViewModelDescriptor pmd = tr.GetViewModelDescriptor(); if (pmd == null) { Logging.Log.ErrorFormat("No matching ViewModelDescriptor found for {0}", mdl.GetType()); return null; } return CreateTemplate(pmd.GetViewDescriptor(Toolkit.WPF, controlKind)); }
/// <summary> /// Creates a specific View for the given ViewModel. /// </summary> /// <param name="mdl">the model to be viewed</param> /// <param name="kind">the kind of view to create</param> /// <returns>the configured view</returns> protected virtual object CreateSpecificView(ViewModel mdl, ControlKind kind) { if (mdl == null) { throw new ArgumentNullException("mdl"); } if (kind == null) { throw new ArgumentNullException("kind"); } ViewModelDescriptor pmd = mdl.GetType().ToRef(FrozenContext) .GetViewModelDescriptor(); var vDesc = pmd.GetViewDescriptor(Toolkit, kind); return(CreateSpecificView(mdl, vDesc)); }
/// <summary> /// Creates a default View for the given ViewModel. /// </summary> /// <param name="mdl">the model to be viewed</param> /// <returns>the configured view</returns> protected virtual object CreateDefaultView(ViewModel mdl) { if (mdl == null) { throw new ArgumentNullException("mdl"); } ViewModelDescriptor pmd = mdl .GetType() .ToRef(FrozenContext) .GetViewModelDescriptor(); var vDesc = mdl.RequestedKind != null ? pmd.GetViewDescriptor(Toolkit, mdl.RequestedKind) : pmd.GetViewDescriptor(Toolkit); return(CreateSpecificView(mdl, vDesc)); }