You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB
C#

using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace StartServerWPF.Modules.Main.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); }
}
private ObservableCollection<MenuItemModel> _children;
public ObservableCollection<MenuItemModel> Children
{
get { return _children; }
set { SetProperty(ref _children, value); }
}
private ICommand _openViewCommand;
public ICommand OpenViewCommand
{
get
{
if (_openViewCommand == null)
_openViewCommand = new DelegateCommand<MenuItemModel>((model) =>
{
var para= new NavigationParameters();
para.Add("model", model.MenuHeader);
if ((model.Children == null || model.Children.Count == 0) &&
!string.IsNullOrEmpty(model.TargetView))
_regionManager.RequestNavigate("MainContentRegion", model.TargetView, para);
else
IsExpanded = !IsExpanded;
});
return _openViewCommand;
}
}
IRegionManager _regionManager = null;
public MenuItemModel(IRegionManager regionManager)
{
_regionManager = regionManager;
}
private bool _isSelected;
public bool IsSelected
{
get => _isSelected;
set
{
SetProperty<bool>(ref _isSelected, value);
}
}
}
}