Is it possible to do the mvvm-light bindings in code in xamarin forms?
I want to do this to be typesafe. If so, is it possible to show me an example?
I've set the binding like this:
button.SetBinding (Button.CommandParameterProperty, "ButtonCommand");
Where the "ButtonCommand" is defined like this in my ViewModel:
public RelayCommand buttonCommand;
public RelayCommand ButtonCommand {
get {
....
}
}
For a typesafe solution:
MyButton.SetBinding<FooViewModel>(ActivityIndicator.IsRunningProperty, model => model.IsBusy);
bool _isBusy;
public bool IsBusy
{
get { return _isBusy; }
set
{
Set(ref _isBusy, value);
LoginCommand.RaiseCanExecuteChanged();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With