using MaterialTraceabilityUI.Common; using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; namespace MaterialTraceabilityUI.ViewModel { public class MainWindowViewModel: NotifyPropertyBase { private readonly string process = ConfigurationManager.AppSettings["ProcessID"]; public CommandBase ChangeContentCommand { get; set; } private FrameworkElement childContent; public FrameworkElement ChildContent { get { return childContent; } set { childContent = value; this.Notify(); } } private bool isShowWait; public bool IsShowWait { get { return isShowWait; } set { isShowWait = value; this.Notify(); } } public MainWindowViewModel() { this.IsShowWait = false; this.ChangeContentCommand = new CommandBase(); this.ChangeContentCommand.ExcuteAction = new Action(DoChangeContent); this.ChangeContentCommand.CanExecuteFunc = new Func(() => true); //涂布CoatingProcess、冷压firstPage、模切DieCuttingProcess this.DoChangeContent(""); } private void DoChangeContent(object param) { if (param.ToString() == "" || param.ToString() == "IndexPage") { // 初始化需要显示的Content对象 if (process == "TB") { param = "CoatingProcess"; } if (process.Contains("LY")) { param = "firstPage"; } if (process.Contains("MQ")) { param = "DieCuttingProcess"; } } Type type = Type.GetType("MaterialTraceabilityUI." + param.ToString()); ConstructorInfo ct1 = type.GetConstructor(System.Type.EmptyTypes); this.ChildContent = (FrameworkElement)ct1.Invoke(null); } } }