this is with regard to the following question on stackoverflow. I am trying to have a touch command for a button as described here but nothing happens. mvvmcross touch command binding in android
<Button
xmlns:local="http://schemas.android.com/apk/res/Test.UI.Droid"
android:text="Office"
android:layout_column="0"
android:id="@+id/imageButton1"
local:MvxBind="{'Touch':{'Path':'ItemClickCommand'}}"/>
public IMvxCommand ItemClickCommand
{
get
{
return new MvxRelayCommand(() => this.RequestNavigate<Tests.OfficeViewModel>(true));
}
}
What am I doing wrong in the above code, why does it not fire.
There’s no binding in place for a
Touchat present.If you wanted to add one, then search on StackOverflow for how to setup a new binding – e.g. the answer in mvvmcross touch command binding in android gives quite a full example.
However… for most button presses, you can probably just use:
Because it’s an
EventHandlerrather than anEventHandler<TCustom>then this binds automagically.i.e.:
should work – and it’s probably what you are looking for – you want to respond to the
Clickof a button, not just aTouch?To debug problems with binding it’s worth looking at the
MvxBindingTraceoutput – normally it will tell you when it can’t bind to things – and if it doesn’t, then please log bugs on github issues 🙂