LoginSignup
0
0

More than 5 years have passed since last update.

ObservableObjectクラス(MVVM Light Toolkit リファレンス)

Last updated at Posted at 2018-10-15

ObservableObject

概要

public class ObservableObject : System.ComponentModel.INotifyPropertyChanged
  • 観測可能(observable)なプロパティをもつオブジェクト(モデル)の基底クラスに使う。
名前空間
  • GalaSoft.MvvmLight

アセンブリ

  • GalaSoft.MvvmLight

メソッド

GetPropertyName

GetPropertyName
protected static string GetPropertyName<T>(System.Linq.Expressions.Expression<System.Func<T>> propertyExpression)
概要
  • propertyExpressionで指定するプロパティの名前を得る。
戻り値
  • propertyExpressionで指定するプロパティの名前。
例外
  • System.ArgumentNullException: propertyExpressionnullである。
  • System.ArgumentException: propertyExpressionで指定したプロパティが存在しない。

RaisePropertyChanged

RaisePropertyChanged
public virtual void RaisePropertyChanged(string propertyName = null)
public virtual void RaisePropertyChanged<T>(System.Linq.Expressions.Expression<System.Func<T>> propertyExpression)
概要
  • propertyNamepropertyExpressionで指定するプロパティに対してPropertyChangedイベントを起こす。
例外
  • System.ArgumentException: 指定した名前を持つプロパティが存在しない。

Set

Set
protected bool Set<T>(string propertyName, ref T field, T newValue)
protected bool Set<T>(System.Linq.Expressions.Expression<System.Func<T>> propertyExpression, ref T field, T newValue)
protected bool Set<T>(ref T field, T newValue, string propertyName = null)
概要
  • fieldnewValueを代入する。
  • fieldの値が変化したら、propertyNamepropertyExpressionを引数にしてRaisePropertyChangedメソッドを呼ぶ。
戻り値
  • fieldの値が変化したらtrue、変化しなかったらfalseを戻す。
例外
  • System.ArgumentException: 指定した名前を持つプロパティが存在しない。

VerifyPropertyName

VerifyPropertyName
public void VerifyPropertyName(string propertyName)
概要
  • propertyNameで指定するプロパティが存在することを確認する。
  • DEBUGビルド時のみ有効。
例外
  • System.ArgumentException: 指定した名前を持つプロパティが存在しない。

プロパティ

PropertyChangedHandler

PropertyChangedHandler
protected System.ComponentModel.PropertyChangedEventHandler PropertyChangedHandler { get; }
概要

PropertyChangedイベントのハンドラーを戻す。

イベント

PropertyChanged

PropertyChanged
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged
概要
  • System.ComponentModel.INotifyPropertyChangedインターフェイスの実装。
  • RaisePropertyChangedメソッドやSetメソッドは、このイベントを起こす。

参照

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0