You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.0 KiB
83 lines
2.0 KiB
using ReactiveUI;
|
|
using HeroIconsAvalonia.Enums;
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace MyAvaloniaApp.ViewModels;
|
|
|
|
/// <summary>
|
|
/// 导航项模型
|
|
/// </summary>
|
|
public class NavigationItem : ReactiveObject
|
|
{
|
|
private string _title = string.Empty;
|
|
private IconType _iconType = IconType.Home;
|
|
private bool _isSelected;
|
|
private bool _isExpanded;
|
|
private IRoutableViewModel? _viewModel;
|
|
private ObservableCollection<NavigationItem> _children = new();
|
|
|
|
/// <summary>
|
|
/// 导航项标题
|
|
/// </summary>
|
|
public string Title
|
|
{
|
|
get => _title;
|
|
set => this.RaiseAndSetIfChanged(ref _title, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导航项图标类型
|
|
/// </summary>
|
|
public IconType IconType
|
|
{
|
|
get => _iconType;
|
|
set => this.RaiseAndSetIfChanged(ref _iconType, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否选中
|
|
/// </summary>
|
|
public bool IsSelected
|
|
{
|
|
get => _isSelected;
|
|
set => this.RaiseAndSetIfChanged(ref _isSelected, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否展开(用于二级导航)
|
|
/// </summary>
|
|
public bool IsExpanded
|
|
{
|
|
get => _isExpanded;
|
|
set => this.RaiseAndSetIfChanged(ref _isExpanded, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导航项的 ViewModel(用于路由导航)
|
|
/// </summary>
|
|
public IRoutableViewModel? ViewModel
|
|
{
|
|
get => _viewModel;
|
|
set => this.RaiseAndSetIfChanged(ref _viewModel, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 子导航项集合(用于二级导航)
|
|
/// </summary>
|
|
public ObservableCollection<NavigationItem> Children
|
|
{
|
|
get => _children;
|
|
set => this.RaiseAndSetIfChanged(ref _children, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导航项标识符
|
|
/// </summary>
|
|
public string Id { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 是否有子项
|
|
/// </summary>
|
|
public bool HasChildren => Children?.Count > 0;
|
|
}
|
|
|