MvvmLight bindings in code?

Is it possible to use mvvm-light bindings in code in a xamarin form?

I want this to be typical. If so, can you show me an example?

+3


source to share


2 answers


For a typical solution:

On your page:

MyButton.SetBinding<FooViewModel>(ActivityIndicator.IsRunningProperty, model => model.IsBusy);

      



In your FooViewModel

    bool _isBusy;
    public bool IsBusy
    {
        get { return _isBusy; }
        set
        {
            Set(ref _isBusy, value);
            LoginCommand.RaiseCanExecuteChanged();
        }
    }

      

+2


source


I have set up the binding like this:

button.SetBinding (Button.CommandParameterProperty, "ButtonCommand");

      



If "ButtonCommand" is defined like this in my ViewModel:

public RelayCommand buttonCommand;

public RelayCommand ButtonCommand {
    get {
        ....
    }
}

      

+3


source







All Articles