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