Files
speckle.xunit.runner.wpf/xunit.runner.wpf/ViewModel/MainViewModel.cs
T
Kevin Pilch-Bisson 70c68bef23 Add some commands
Got the stuff for the ApplicationCommands.Open from
https://codingcontext.wordpress.com/2008/12/10/commandbindings-in-mvvm/.
2015-08-08 18:11:55 -07:00

50 lines
1.3 KiB
C#

using GalaSoft.MvvmLight;
using System.Windows.Input;
using System;
using System.Windows;
using GalaSoft.MvvmLight.CommandWpf;
namespace xunit.runner.wpf.ViewModel
{
public class MainViewModel : ViewModelBase
{
public MainViewModel()
{
////if (IsInDesignMode)
////{
//// // Code runs in Blend --> create design time data.
////}
////else
////{
//// // Code runs "for real"
////}
}
public ICommand ExitCommand { get; } = new RelayCommand(OnExecuteExit);
public CommandBindingCollection CommandBindings { get; }
= CreateCommandBindings();
private static CommandBindingCollection CreateCommandBindings()
{
var openBinding = new CommandBinding(ApplicationCommands.Open, OnExecuteOpen);
CommandManager.RegisterClassCommandBinding(typeof(MainViewModel), openBinding);
return new CommandBindingCollection
{
openBinding,
};
}
private static void OnExecuteOpen(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Open clicked");
}
private static void OnExecuteExit()
{
Application.Current.Shutdown();
}
}
}