Skip to content

Instantly share code, notes, and snippets.

@runegri
Created September 11, 2014 20:06
Show Gist options
  • Save runegri/27aaecc16138ebdefca7 to your computer and use it in GitHub Desktop.
Save runegri/27aaecc16138ebdefca7 to your computer and use it in GitHub Desktop.
skulle vel funke denne?
// 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