mirror of
https://github.com/PacktPublishing/Learn-WinUI-3-Second-Edition.git
synced 2026-06-20 12:23:09 +00:00
28 lines
799 B
C#
28 lines
799 B
C#
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace MyMediaCollection.ViewModels
|
|
{
|
|
public class BindableBase : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
protected bool SetProperty<T>(ref T originalValue, T newValue, [CallerMemberName] string propertyName = null)
|
|
{
|
|
if (Equals(originalValue, newValue))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
originalValue = newValue;
|
|
OnPropertyChanged(propertyName);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
} |