Helpers/MvvmLightDemo/ViewModel/MainViewModel.cs
2019-08-02 16:19:14 +08:00

31 lines
675 B
C#

using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
namespace MvvmLightDemo.ViewModel
{
public class MainViewModel : ViewModelBase
{
private string _Title;
public string Title
{
get => _Title;
set => Set(ref _Title, value);
}
public ICommand ChangeTitleCommand { get; set; }
public MainViewModel()
{
Title = "Hello World!";
ChangeTitleCommand = new RelayCommand(ChangeTitle);
}
private void ChangeTitle()
{
Title = "Hello MvvmLight!";
}
}
}