Skip to content
riesling-alsacePublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

Repository files navigation

Description

MVVMの基礎クラスとしてINotifyPropertyChangedから派生させた、BindableBase(汎用)とViewModelBase(ViewModel用)を実装しました。

ViewModelBaseはマルチスレッドも対応しています。通知を送る際にサブスレッドであればメインスレッドで通知を呼び出すようになっています。

BindableBase

public class SampleModel : BindableBase {
  private string _Title;
  public string Title {
    get => _Title;
    set => SetProperty(ref _Title, value, TitleChanged);
  }

  protected void TitleChanged(string newValue, string oldValue) {
    // TODO
  }
}

ViewModelBase(WPF/MAUI)

public class SampleViewModel : ViewModelBase<SampleModel> {
  public string Title {
    get => Model.Title;
    set => Model.Title = value;
  }

  protected override void Model_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    switch (e.PropertyName) {
    case nameof(SampleModel.Title):
      RaisePropertyChanged(nameof(Title));
      break;
    }
  }
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors