Ejemplo n.º 1
0
        public FrameworkElement GetControl(Guid?id)
        {
            if (GetDesignControl != null)
            {
                return(GetDesignControl(id));
            }
            var c = GetViewControl(id);

            if (c != null)
            {
                return(DesignManager.CreateDesignControl(c));
            }
            c = new FaildControl();
            return(DesignManager.CreateDesignControl(c));
        }
Ejemplo n.º 2
0
        FrameworkElement GetViewControl(Guid?id)
        {
            var view      = Activator.CreateInstance(ViewType) as FrameworkElement;
            var viewModel = Activator.CreateInstance(ViewModelType);
            var property  = ViewModelType.GetProperty("Target");

            if (property == null)
            {
                property = ViewModelType.GetProperty("TargetObject");
            }
            if (property == null)
            {
                property = ViewModelType.GetProperty("DataObject");
            }
            if (property != null)
            {
                property.SetValue(viewModel, DesignManager.GetObject(id));
            }


            view.DataContext = viewModel;
            return(view);
        }