using ReactiveUI;
using HeroIconsAvalonia.Enums;
using System;
using System.Collections.ObjectModel;
namespace MyAvaloniaApp.ViewModels;
///
/// 导航项模型
///
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 _children = new();
///
/// 导航项标题
///
public string Title
{
get => _title;
set => this.RaiseAndSetIfChanged(ref _title, value);
}
///
/// 导航项图标类型
///
public IconType IconType
{
get => _iconType;
set => this.RaiseAndSetIfChanged(ref _iconType, value);
}
///
/// 是否选中
///
public bool IsSelected
{
get => _isSelected;
set => this.RaiseAndSetIfChanged(ref _isSelected, value);
}
///
/// 是否展开(用于二级导航)
///
public bool IsExpanded
{
get => _isExpanded;
set => this.RaiseAndSetIfChanged(ref _isExpanded, value);
}
///
/// 导航项的 ViewModel(用于路由导航)
///
public IRoutableViewModel? ViewModel
{
get => _viewModel;
set => this.RaiseAndSetIfChanged(ref _viewModel, value);
}
///
/// 子导航项集合(用于二级导航)
///
public ObservableCollection Children
{
get => _children;
set => this.RaiseAndSetIfChanged(ref _children, value);
}
///
/// 导航项标识符
///
public string Id { get; set; } = string.Empty;
///
/// 是否有子项
///
public bool HasChildren => Children?.Count > 0;
}