Skip to content

Instantly share code, notes, and snippets.

@slodge
Last active December 13, 2015 19:28
public class MvxTextViewTextColorBinding
: MvxBaseAndroidTargetBinding
{
private readonly TextView _textView;
public MvxTextViewTextColorBinding(TextView textView)
{
_textView = textView;
}
public override void SetValue(object value)
{
_textView.SetTextColor((Color)value);
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
public override Type TargetType
{
get { return typeof(Color); }
}
}
public class MvxViewBackgroundColorBinding
: MvxBaseAndroidTargetBinding
{
private readonly View _view;
public MvxViewBackgroundColorBinding(View view)
{
_view = view;
}
public override void SetValue(object value)
{
_view.SetBackgroundColor((Color)value);
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
public override Type TargetType
{
get { return typeof(Color); }
}
}
protected override void FillTargetFactories(Cirrious.MvvmCross.Binding.Interfaces.Bindings.Target.Construction.IMvxTargetBindingFactoryRegistry registry)
{
registry.RegisterFactory(new MvxCustomBindingFactory<View>("BackgroundColor", textView => new MvxViewBackgroundColorBinding(textView)));
registry.RegisterFactory(new MvxCustomBindingFactory<TextView>("TextColor", textView => new MvxTextViewTextColorBinding(textView)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment