2025-08-15 15:25:44 +08:00

80 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Windows.Input;
using Prism.Ioc;
using Prism.Services.Dialogs;
using Telerik.Windows.Controls;
using Unity;
namespace DI_Electrical.ViewModels
{
/// <summary>
/// abstract 不同于接口,可以实现具体的代码
/// </summary>
public abstract class DialogBase : ViewModelBase
{
public DialogBase()
{
window_loaded = new DelegateCommand(onWindow_loaded);
CloseCommand = new DelegateCommand(ExecuteCloseCommand);
OKCommand = new DelegateCommand(ExecuteOKCommandAsync);
}
#region binding
private bool _isbusy;
public bool IsBusy
{
get { return _isbusy; }
set { _isbusy = value; RaisePropertyChanged(nameof(IsBusy)); }
}
private string _BusyContent;
public string BusyContent
{
get { return _BusyContent; }
set { _BusyContent = value; RaisePropertyChanged(nameof(BusyContent)); }
}
/// <summary>
/// 加载后
/// </summary>
public ICommand window_loaded { get; }
public ICommand CloseCommand { get; }
public ICommand OKCommand { get; }
private string _title;
public string title
{
get { return _title; }
set { _title = value; RaisePropertyChanged(nameof(title)); }
}
#endregion
IUnityContainer _unityContainer;
/// <summary>
/// CODE-BEHAND里设置为this.close以关闭。调用时.invoke即可
/// </summary>
public Action CloseWindowAction { get; set; }
/// <summary>
/// virtual 可以重写
/// </summary>
/// <param name="parameter"></param>
public virtual void ExecuteCloseCommand(object parameter)
{
// 关闭窗口 (需要通过 CommandParameter 传入窗口实例)
if (parameter is System.Windows.Window window)
{
window.Close();
}
}
public virtual void onWindow_loaded(object para)
{
}
public virtual void ExecuteOKCommandAsync(object para)
{
}
}
}