using GalaSoft.MvvmLight; using JianGongYun.Models; using JianGongYun.Views; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Windows.Controls; using System.Windows.Data; namespace JianGongYun.ViewModel.ModuleViewModel { public class PracticalCaseViewModel : ViewModelBase { public PracticalCaseViewModel() { #region 控件 _ControlList = new List() { new ControlModel("Win10菜单", typeof(Window1)), new ControlModel("Win10菜单cccc", typeof(Window2)), new ControlModel("教学计划", typeof(TeachingPlan)) }; _AllControl.Source = _ControlList; _AllControl.View.Culture = new System.Globalization.CultureInfo("zh-CN"); #endregion } #region 控件 private IEnumerable _ControlList; /// /// 所有控件 /// public IEnumerable AllControl { get { return _ControlList; } set { Set(ref _ControlList, value); } } private CollectionViewSource _AllControl=new CollectionViewSource(); /// /// 所有控件 /// public CollectionViewSource AllControlViewSource { get { return _AllControl; } set { Set(ref _AllControl, value); } } #endregion private ControlModel _CurrentShowControl = null; /// /// 当前显示控件 /// public ControlModel CurrentShowControl { get { return _CurrentShowControl; } set { Set(ref _CurrentShowControl, value); RaisePropertyChanged("Content"); } } /// /// 控件显示 /// private UserControl _content; public UserControl Content { get { if (CurrentShowControl == null) return null; return (UserControl)Activator.CreateInstance(CurrentShowControl.Content); } set { Set(ref _content, value); } } } }