Created
July 17, 2015 03:53
-
-
Save jassmith/fc4cf31b45c73c91e68e to your computer and use it in GitHub Desktop.
This file contains 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 SliderViewModel : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
private double limitedValue = 10; | |
public double LimitedValue | |
{ | |
get { return limitedValue; } | |
set | |
{ | |
value = Math.Min (value, 50); | |
limitedValue = value; | |
Debug.WriteLine (limitedValue); | |
OnPropertyChanged (); | |
} | |
} | |
protected virtual void OnPropertyChanged ([CallerMemberName] string propertyName = null) | |
{ | |
var handler = PropertyChanged; | |
if (handler != null) | |
handler (this, new PropertyChangedEventArgs (propertyName)); | |
} | |
} | |
var contentPage = new ContentPage (); | |
contentPage.BindingContext = new SliderViewModel (); | |
var slider = new Slider { | |
Minimum = 0, | |
Maximum = 100, | |
VerticalOptions = LayoutOptions.CenterAndExpand | |
}; | |
slider.SetBinding (Slider.ValueProperty, "LimitedValue"); | |
contentPage.Content = slider; | |
MainPage = contentPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment