2025-04-01 13:41:50 +08:00

46 lines
1.3 KiB
C#

using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System.Collections.Generic;
using System.Windows.Input;
namespace RIZO.Client.MainModule.Models
{
public class MenuItemModel : BindableBase
{
public string MenuIcon { get; set; }
public string MenuHeader { get; set; }
public string TargetView { get; set; }
private bool _isExpanded;
public bool IsExpanded
{
get { return _isExpanded; }
set { SetProperty(ref _isExpanded, value); }
}
public List<MenuItemModel> Children { get; set; }
public ICommand OpenViewCommand
{
get => new DelegateCommand(() =>
{
if ((this.Children == null || this.Children.Count == 0) &&
!string.IsNullOrEmpty(this.TargetView))
{
// 页面跳转
_regionManager.RequestNavigate("MainContentRegion", this.TargetView);
}
else
this.IsExpanded = !this.IsExpanded;
});
}
IRegionManager _regionManager = null;
public MenuItemModel(IRegionManager regionManager)
{
_regionManager = regionManager;
}
}
}