Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Input;
using MaterialDesign.Dialog.Example.Services;
using Prism.Commands;
using Prism.Mvvm;
namespace MaterialDesign.Dialog.Example.ViewModels
{
public class ShellViewModel : BindableBase
{
private readonly IDialogService _dialogService;
[Obsolete("実際には使用しないが、デフォルトコンストラクタがないとXAML デザイナー上でバインドしたときに警告出るので仕方なく追加しておく。")]
public ShellViewModel()
{
}
public ShellViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
ShutdownCommand = new DelegateCommand(async () =>
{
bool result = await _dialogService.Question("終了します。よろしいですか?");
if (result)
{
App.Current.MainWindow.Close();
}
});
}
public ICommand ShutdownCommand { get; private set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment