using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using HandyControl.Controls;
namespace SparkClient.ViewModel.BaseWindow;
public class BaseControlVM : BaseViewModel
{
string _windowTitle;
private Visibility _showFunctionButton;
private string _functionButtonIcon;
private Object _viewContent;
public string WindowTitle { get { return _windowTitle; } set { _windowTitle = value; OnPropertyChanged("WindowTitle"); } }
public Visibility ShowFunctionButton { get { return _showFunctionButton; } set { _showFunctionButton = value; OnPropertyChanged("ShowFunctionButton"); } }
public string FunctionButtonIcon { get { return _functionButtonIcon; } set { _functionButtonIcon = value; OnPropertyChanged("FunctionButtonIcon"); } }
public Object ViewControl { get { return _viewContent; } set { _viewContent = value; OnPropertyChanged("ViewControl"); } }
public object Content { get; }
public ICommand CloseCommand { get; }
///
/// 构造:创建一个带有子页面的模板,并指定子窗口标题,并指定右侧按钮事件内容
///
/// 子页面
/// 子窗口标题
/// 事件内哦那个
public BaseControlVM(BaseViewModel vm, string windowTitle, ICommand Function)
{
Content = vm;
WindowTitle = windowTitle;
CloseCommand = new RelayCommand(CloseVM);
}
///
/// 构造:创建一个带有子页面的模板,并指定子窗口标题
///
/// 子页面
/// 子窗口标题
public BaseControlVM(BaseViewModel vm, string windowTitle)
{
Content = vm;
WindowTitle = windowTitle;
CloseCommand = new RelayCommand(CloseVM);
}
///
/// 构造:创建一个带有子页面的模板
///
///
public BaseControlVM(BaseViewModel vm)
{
Content = vm;
CloseCommand = new RelayCommand(CloseVM);
}
///
/// 关闭并退回至上一个页面
///
///
public void CloseVM(object parameter)
{
WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
}
}