Created
September 11, 2014 20:06
-
-
Save runegri/27aaecc16138ebdefca7 to your computer and use it in GitHub Desktop.
skulle vel funke denne?
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
// View Model: | |
public class ValueViewModel : ViewModel | |
{ | |
private bool _checked; | |
public bool Checked | |
{ | |
get { return _checked; } | |
set | |
{ | |
_checked = value; | |
NotifyPropertyChanged(); | |
NotifyPropertyChanged("StatusColor"); | |
} | |
} | |
public Color StatusColor | |
{ | |
get { return Checked ? Color.Green : Color.Red; } | |
} | |
} | |
// View: | |
public class ValueView : ContentView | |
{ | |
public ValueView() | |
{ | |
var layout = new Label | |
{ | |
XAlign = TextAlignment.Center, | |
YAlign = TextAlignment.Center, | |
Font = Font.BoldSystemFontOfSize(NamedSize.Medium), | |
}; | |
layout.SetBinding(Label.TextProperty, "Name"); | |
layout.SetBinding(Label.BackgroundColorProperty, new Binding("StatusColor", BindingMode.TwoWay)); | |
Content = layout; | |
} | |
} | |
// Setter BindingContext fra MainView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment