borepin/Borepin/Borepin/PageModel/MachinesPageModel.cs
2021-01-29 22:54:35 +01:00

51 lines
1.5 KiB
C#

using Borepin.Model;
using Prism.Mvvm;
using Prism.Navigation;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel
{
public class MachinesPageModel : BindableBase
{
private readonly INavigationService _NavigationService;
public MachinesPageModel(INavigationService navigationService)
{
_NavigationService = navigationService;
GoToMachineCommand = new Command<object>(GoToMachineCommandExecuted);
}
private ICommand _GoToMachineCommand;
public ICommand GoToMachineCommand
{
get => _GoToMachineCommand;
set => SetProperty(ref _GoToMachineCommand, value);
}
private async void GoToMachineCommandExecuted(object obj)
{
Machine machine = obj as Machine;
NavigationParameters navigationParams = new NavigationParameters
{
{ "machineID", machine.ID }
};
INavigationResult result = await _NavigationService.NavigateAsync($"MachinePage", navigationParams);
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
private ObservableCollection<Machine> _MachineList;
public ObservableCollection<Machine> MachineList
{
get => _MachineList;
set => SetProperty(ref _MachineList, value);
}
}
}