59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
|
|
using Prism.Commands;
|
|||
|
|
using Prism.Mvvm;
|
|||
|
|
using Prism.Regions;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows.Input;
|
|||
|
|
|
|||
|
|
namespace Cowain.Bake.Main.Models
|
|||
|
|
{
|
|||
|
|
public class MenuItemModel : BindableBase
|
|||
|
|
{
|
|||
|
|
public string MenuIcon { get; set; }
|
|||
|
|
public string MenuHeader { get; set; }
|
|||
|
|
public string HeaderName { get; set; }
|
|||
|
|
public string TargetView { get; set; }
|
|||
|
|
|
|||
|
|
private bool isExpanded;
|
|||
|
|
|
|||
|
|
public bool IsExpanded
|
|||
|
|
{
|
|||
|
|
get { return isExpanded; }
|
|||
|
|
set { SetProperty(ref isExpanded, value); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool isDefault;
|
|||
|
|
|
|||
|
|
public bool IsDefault
|
|||
|
|
{
|
|||
|
|
get { return isDefault; }
|
|||
|
|
set { SetProperty(ref isDefault, 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))
|
|||
|
|
{
|
|||
|
|
// 页面跳转 使用IRegionManager.RequestNavigate()跳转到目标页面
|
|||
|
|
_regionManager.RequestNavigate("MainContentRegion", this.TargetView);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
this.IsExpanded = !this.IsExpanded;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
IRegionManager _regionManager = null;
|
|||
|
|
public MenuItemModel(IRegionManager regionManager)
|
|||
|
|
{
|
|||
|
|
_regionManager = regionManager;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|