Пример #1
0
        /// <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));
        }
Пример #2
0
        /// <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));
        }
Пример #3
0
        private static DataTemplate SelectDefaultTemplate(ViewModel mdl, 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)));
        }