vue-java-tutorials/CSharp/WPFTutorial/WPF-13-INotifyPropertyChanged/ViewModels/MainWindowViewModel.cs

45 lines
853 B
C#
Raw Permalink Normal View History

2025-06-22 20:21:42 +08:00
using System.Windows;
using WPF_13_INotifyPropertyChanged.Command;
namespace WPF_13_INotifyPropertyChanged.ViewModels;
public class MainWindowViewModel : ViewModelBase
{
private string? _content;
private string? _title;
public MainWindowViewModel()
{
ShowCommand = new ShowCommand(Show);
}
public string? Title
{
get => _title;
set
{
_title = value;
OnPropertyChanged();
}
}
public string? Content
{
get => _content;
set
{
_content = value;
OnPropertyChanged();
}
}
public ShowCommand ShowCommand { get; set; }
private void Show()
{
Content = "Hello World";
Title = "Hello World---Title";
MessageBox.Show($"👼👼👼:{Content}");
}
}