Files
ADP/DeviceEditModule/ViewModels/DialogTabItemVM.cs
2026-06-12 16:55:47 +08:00

61 lines
1.9 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 Prism.Commands;
using Prism.Mvvm;
using System;
namespace DeviceEditModule.ViewModels
{
/// <summary>
/// 弹窗管理器中单个 Tab 项的 ViewModel。
/// 由 <see cref="DialogMangerViewModel"/> 在收到 AddDialogTabEvent 时创建,
/// 通过构造函数注入选中/关闭的回调,保持与父 ViewModel 的低耦合。
/// </summary>
public class DialogTabItemVM : BindableBase
{
#region
private string _title = string.Empty;
/// <summary>Tab 标签页上显示的标题。</summary>
public string Title
{
get => _title;
set => SetProperty(ref _title, value);
}
private object? _content;
/// <summary>Tab 内容区域(通常为 UserControl 实例)。</summary>
public object? Content
{
get => _content;
set => SetProperty(ref _content, value);
}
private bool _isSelected;
/// <summary>是否为当前激活 Tab用于切换选中态样式。</summary>
public bool IsSelected
{
get => _isSelected;
set => SetProperty(ref _isSelected, value);
}
#endregion
#region
/// <summary>点击 Tab 标题激活该 Tab。</summary>
public DelegateCommand SelectCommand { get; }
/// <summary>点击 Tab 上的 × 关闭并移除该 Tab。</summary>
public DelegateCommand CloseCommand { get; }
#endregion
/// <param name="onSelect">父 VM 提供的激活回调。</param>
/// <param name="onClose">父 VM 提供的关闭回调。</param>
public DialogTabItemVM(Action<DialogTabItemVM> onSelect, Action<DialogTabItemVM> onClose)
{
SelectCommand = new DelegateCommand(() => onSelect(this));
CloseCommand = new DelegateCommand(() => onClose(this));
}
}
}