You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nate Turley edited this page Mar 11, 2020
·
3 revisions
Anatomy of a Bindable Property
public string Text
{
get { return _text; } // Getter returns backing field
set
{
if (value != _text) // Only update field if value is changed
{
_text = value; // Set backing field
NotifyPropertyChanged(nameof(Text)); // Alert subscribers to change in Property with name of property
}
}
}
[SerializeField]
string _text;
Visual Studio Code Snippet
Included in Unity-MVVM is a Visual Studio code snippet which is helpful for writing bindable properties in your ViewModel. To install on Windows, open the .snippet file with Visual Studio.
Once this is installed type bindprop + (Tabx2) to create a bindable property snippet