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.
 
 
 
 

82 lines
1.9 KiB

using ReactiveUI;
using HeroIconsAvalonia.Enums;
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 object? _content;
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>
/// 导航项内容
/// </summary>
public object? Content
{
get => _content;
set => this.RaiseAndSetIfChanged(ref _content, 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;
}