JianGongYun/JianGongYun/ViewModel/ModuleViewModel/PracticalCaseViewModel.cs

92 lines
2.4 KiB
C#

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<ControlModel>()
{
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<ControlModel> _ControlList;
/// <summary>
/// 所有控件
/// </summary>
public IEnumerable<ControlModel> AllControl
{
get { return _ControlList; }
set { Set(ref _ControlList, value); }
}
private CollectionViewSource _AllControl=new CollectionViewSource();
/// <summary>
/// 所有控件
/// </summary>
public CollectionViewSource AllControlViewSource
{
get { return _AllControl; }
set
{
Set(ref _AllControl, value);
}
}
#endregion
private ControlModel _CurrentShowControl = null;
/// <summary>
/// 当前显示控件
/// </summary>
public ControlModel CurrentShowControl
{
get
{
return _CurrentShowControl;
}
set
{
Set(ref _CurrentShowControl, value);
RaisePropertyChanged("Content");
}
}
/// <summary>
/// 控件显示
/// </summary>
private UserControl _content;
public UserControl Content
{
get
{
if (CurrentShowControl == null)
return null;
return (UserControl)Activator.CreateInstance(CurrentShowControl.Content);
}
set
{
Set(ref _content, value);
}
}
}
}