Skip to content

Instantly share code, notes, and snippets.

@JoeM-RP
Created April 30, 2018 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeM-RP/206d6007c9ea6fe612e253cfa70ff1d3 to your computer and use it in GitHub Desktop.
Save JoeM-RP/206d6007c9ea6fe612e253cfa70ff1d3 to your computer and use it in GitHub Desktop.
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace samples.core.Models
{
public class RadioOption : INotifyPropertyChanged
{
public RadioCategory Category { get; }
public string Title { get; }
private bool _isSelected { get; set; }
public bool IsSelected
{
get => _isSelected;
set
{
if(value != _isSelected)
{
this._isSelected = value;
NotifyPropertyChanged();
}
}
}
public RadioOption(RadioCategory category, string title, bool isSelected = false)
{
this.Category = category;
this.Title = title;
this.IsSelected = isSelected;
}
public event PropertyChangedEventHandler PropertyChanged;
// This method is called by the Set accessor of each property.
// The CallerMemberName attribute that is applied to the optional propertyName
// parameter causes the property name of the caller to be substituted as an argument.
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public enum RadioCategory
{
CategoryA,
CategoryB,
CategoryC,
CategoryD
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment