INotifyPropertyChanged.PropertyChanged イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > INotifyPropertyChanged.PropertyChanged イベントの意味・解説 

INotifyPropertyChanged.PropertyChanged イベント

メモ : このイベントは、.NET Framework version 2.0新しく追加されたものです。

プロパティ値が変更されたときに発生します

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Event PropertyChanged As PropertyChangedEventHandler
Dim instance As INotifyPropertyChanged
Dim handler As PropertyChangedEventHandler

AddHandler instance.PropertyChanged, handler
event PropertyChangedEventHandler PropertyChanged
event PropertyChangedEventHandler^ PropertyChanged {
    void add (PropertyChangedEventHandler^ value);
    void remove (PropertyChangedEventHandler^ value);
}
/** @event */
void add_PropertyChanged (PropertyChangedEventHandler value)

/** @event */
void remove_PropertyChanged (PropertyChangedEventHandler value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説

PropertyChanged イベントでは、PropertyChangedEventArgs のプロパティ名に null 参照 (Visual Basic では Nothing) または String.Empty のいずれか使用することによって、オブジェクトすべてのプロパティ変更されたことを示すことができます

使用例使用例

INotifyPropertyChanged インターフェイスPropertyChanged イベント実装する方法次のコード例示します

' This class implements a simple customer type 
' that implements the IPropertyChange interface.

Public Class DemoCustomer
    Implements INotifyPropertyChanged
    ' These fields hold the values for the public properties.
    Private idValue As Guid = Guid.NewGuid()
    Private customerName As String
 = String.Empty
    Private companyNameValue As String
 = String.Empty
    Private phoneNumberValue As String
 = String.Empty
    
    Public Event PropertyChanged As
 PropertyChangedEventHandler _
        Implements INotifyPropertyChanged.PropertyChanged
    
    
    Private Sub NotifyPropertyChanged(ByVal
 info As String) 
        RaiseEvent PropertyChanged(Me, New
 PropertyChangedEventArgs(info))
    End Sub

    ' The constructor is private to enforce the factory pattern.
    Private Sub New() 
        customerName = "no data"
        companyNameValue = "no data"
        phoneNumberValue = "no data"
    
    End Sub
    
    
    ' This is the public factory method.
    Public Shared Function
 CreateNewCustomer() As DemoCustomer 
        Return New DemoCustomer()
    
    End Function
    
    ' This property represents an ID, suitable
    ' for use as a primary key in a database.
    Public ReadOnly Property
 ID() As Guid
        Get
            Return Me.idValue
        End Get
    End Property
    
    
    Public Property CompanyName() As
 String 
        Get
            Return Me.companyNameValue
        End Get
        
        Set(ByVal value As
 String)
            If Not (value = companyNameValue)
 Then
                Me.companyNameValue = value
                NotifyPropertyChanged("CompanyName")
            End If
        End Set
    End Property
    
    
    Public Property PhoneNumber() As
 String 
        Get
            Return Me.phoneNumberValue
        End Get
        
        Set(ByVal value As
 String)
            If Not (value = phoneNumberValue)
 Then
                Me.phoneNumberValue = value
                NotifyPropertyChanged("PhoneNumber")
            End If

        End Set
    End Property
End Class
// This class implements a simple customer type 
// that implements the IPropertyChange interface.
public class DemoCustomer : INotifyPropertyChanged
{
    // These fields hold the values for the public properties.
    private Guid idValue = Guid.NewGuid();
    private string customerName = String.Empty;
    private string companyNameValue = String.Empty;
    private string phoneNumberValue = String.Empty;

    public event PropertyChangedEventHandler PropertyChanged;
    
    private void NotifyPropertyChanged(String
 info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    }

    // The constructor is private to enforce the factory pattern.
    private DemoCustomer()
    {
        customerName = "no data";
        companyNameValue = "no data";
        phoneNumberValue = "no data";
    }

    // This is the public factory method.
    public static DemoCustomer CreateNewCustomer()
    {
        return new DemoCustomer();
    }

    // This property represents an ID, suitable
    // for use as a primary key in a database.
    public Guid ID
    {
        get
        {
            return this.idValue;
        }
    }

    public string CompanyName
    {
        get
        {
            return this.companyNameValue;
        }

        set
        {
            if (value != this.companyNameValue)
            {
                this.companyNameValue = value;
                NotifyPropertyChanged("CompanyName");
            }
        }
    }

    public string PhoneNumber
    {
        get
        {
            return this.phoneNumberValue;
        }

        set
        {
            if (value != this.companyNameValue)
            {
                this.phoneNumberValue = value;
                NotifyPropertyChanged("PhoneNumber");
            }
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
INotifyPropertyChanged インターフェイス
INotifyPropertyChanged メンバ
System.ComponentModel 名前空間
PropertyChangedEventArgs


このページでは「.NET Framework クラス ライブラリ リファレンス」からINotifyPropertyChanged.PropertyChanged イベントを検索した結果を表示しています。
Weblioに収録されているすべての辞書からINotifyPropertyChanged.PropertyChanged イベントを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からINotifyPropertyChanged.PropertyChanged イベント を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「INotifyPropertyChanged.PropertyChanged イベント」の関連用語

INotifyPropertyChanged.PropertyChanged イベントのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



INotifyPropertyChanged.PropertyChanged イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS