Created
September 3, 2017 13:08
-
-
Save Odonno/5ef11691ad302fc510043838c0a45a1f to your computer and use it in GitHub Desktop.
Example of a ViewModel used in C#/XAML MonoGame app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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