MessengerInstance
がRaisePropertyChanged()メソッドで使用されている:あなたはビューのプロパティにそれを使用することができ
<summary>
/// Raises the PropertyChanged event if needed, and broadcasts a
/// PropertyChangedMessage using the Messenger instance (or the
/// static default instance if no Messenger instance is available).
///
/// </summary>
/// <typeparam name="T">The type of the property that
/// changed.</typeparam>
/// <param name="propertyName">The name of the property
/// that changed.</param>
/// <param name="oldValue">The property's value before the change
/// occurred.</param>
/// <param name="newValue">The property's value after the change
/// occurred.</param>
/// <param name="broadcast">If true, a PropertyChangedMessage will
/// be broadcasted. If false, only the event will be raised.</param>
protected virtual void RaisePropertyChanged<T>(string propertyName, T oldValue, T
newValue, bool broadcast);
例えば、モデルB:
public const string SelectedCommuneName = "SelectedCommune";
private communes selectedCommune;
public communes SelectedCommune
{
get { return selectedCommune; }
set
{
if (selectedCommune == value)
return;
var oldValue = selectedCommune;
selectedCommune = value;
RaisePropertyChanged(SelectedCommuneName, oldValue, value, true);
}
}
キャッチそれとでビューモデルAにそれに対処:
Messenger.Default.Register<PropertyChangedMessage<communes>>(this, (nouvelleCommune) =>
{
//Actions to perform
Client.Ville = nouvelleCommune.NewValue.libelle;
Client.CodePays = nouvelleCommune.NewValue.code_pays;
Client.CodePostal = nouvelleCommune.NewValue.code_postal;
});
希望すると便利です:)
ありがとうございます!今すぐクリア!^_ ^ – kidgu