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