Skip to content

Instantly share code, notes, and snippets.

@Odonno
Created September 3, 2017 13:08
Show Gist options
  • Save Odonno/5ef11691ad302fc510043838c0a45a1f to your computer and use it in GitHub Desktop.
Save Odonno/5ef11691ad302fc510043838c0a45a1f to your computer and use it in GitHub Desktop.
Example of a ViewModel used in C#/XAML MonoGame app
public class ScoreViewModel : BaseViewModel, IScoreViewModel
{
#region Properties
private static IScoreViewModel _instance;
public static IScoreViewModel Instance { get { return _instance ?? (_instance = new ScoreViewModel()); } }
private float _distanceMax;
public float DistanceMax
{
get
{
return _distanceMax;
}
set
{
_distanceMax = value;
RaisePropertyChanged();
RaisePropertyChanged("Score");
}
}
private float _ballPoints;
public float BallPoints
{
get
{
return _ballPoints;
}
set
{
_ballPoints = value;
RaisePropertyChanged();
RaisePropertyChanged("Score");
}
}
public int Score { get { return (int)(_ballPoints * _distanceMax); } }
#endregion
#region Constructor
private ScoreViewModel() { }
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment