Reputation: 11712
Is it possible to Bind Android TextView to Click event with MvvmCross? Or as alternative make a button which looks like TextView?
Upvotes: 5
Views: 3109
Reputation: 994
As the OP may be interested in methods to achieve click binding from code-behind as opposed to xml I have provided the following for guidance:
using MvvmCross.Platforms.Android.Binding;
var set = this.CreateBindingSet<theActivity,theViewModel>();
imageView1.For(x=> x.BindClick()).To(vm=>vm.imageViewClickCmd);
set.Apply()
The MvvmCross.Platforms.Android.Binding namespace provides the BindClick() extension method. Similar methods can be found for alternative events at the following links https://www.mvvmcross.com/documentation/fundamentals/data-binding#built-in-bindings
Alternatively you can use
imageView1.For("Click").To(vm=>vm.imageViewClickCmd);
Upvotes: 2
Reputation: 903
You can bind a text view like this.
<TextView android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
local:MvxBind="Click DoThisCommand" />
height and width you can manage according to your convinience. Hope this will help you.
Upvotes: 2
Reputation: 11712
It is turned out that TextView can be bound same way as Button
local:MvxBind="Click DoCommand"
Upvotes: 10