I\'m trying to create an MvxTabsFragmentActivity
and bind a button on a fragment to a command. The problem I\'m getting is the following error.
MvxB
I don't think this has anything to do with Fragment
s
Standard Button
s in Android don't have Command
properties - they have Click
events.
They also don't have CommandParameter
properties - but MvvmCross provides a CommandParameter
converter to allow you to do bindings like:
local:MvxBind="Click CommandParameter(VMCommandName, VMCommandParameterName)"
If you want to add Command
and CommandParameter
to a MyButton
this can be done quite easily:
public class MyButton : Button {
public MyButton(Context c, IAttributeSet a) : base (c, a) {
Click += (s,e) => {
if (Command == null) return;
if (!Command.CanExecute(CommandParameter)) return;
Command.Execute(CommandParameter);
}
}
public ICommand Command {get;set;}
public object CommandParameter {get;set;}
}
Used in axml as: