设备编辑管理界面
This commit is contained in:
19
UIShare/UIViewModel/DialogTabInfo.cs
Normal file
19
UIShare/UIViewModel/DialogTabInfo.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 弹窗 Tab 信息载体(事件负载,轻量 POCO)。
|
||||
/// 其他模块发布 <c>AddDialogTabEvent</c> 时填充此对象,
|
||||
/// DialogMangerViewModel 接收后创建对应的 Tab 项。
|
||||
/// </summary>
|
||||
public class DialogTabInfo
|
||||
{
|
||||
/// <summary>Tab 标题(显示在标签页上)。</summary>
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Tab 内容:传入一个已实例化的 <see cref="System.Windows.FrameworkElement"/>(通常是 UserControl),
|
||||
/// 由 ContentControl 直接承载展示。
|
||||
/// </summary>
|
||||
public object? Content { get; set; }
|
||||
}
|
||||
}
|
||||
60
UIShare/UIViewModel/DialogTabItemVM.cs
Normal file
60
UIShare/UIViewModel/DialogTabItemVM.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user