Amit
Amit

Reputation: 227

How to do control binding in code for MonoDroid?

I am facing an issue with control binding in code in mono droid. I have an activity inheriting from MvxActivity and I saw some article to perform data binding in code using CreateBindingSet(). Can someone tell me what assembly reference I need on my monodroid project to get this method? If possible, can someone help me out with a sample example as well?

I am using V3 of MvvmCross.

Thanks Amit

Upvotes: 2

Views: 578

Answers (1)

Cheesebaron
Cheesebaron

Reputation: 24460

You need to have a using Cirrious.MvvmCross.Binding.BindingContext; and then you should be able to use Bind() on stuff.

Take a look at the DialogExamples Tutorial in the MvvmCross-Tutorial repository.

Binding is pretty simple, you need to create a binding set first:

var bSet = this.CreateBindingSet<TView, TViewModel>

Then you can use that to Bind UI objects:

bSet.Bind(myTextView)
    .For(v => v.Text) //View Property
    .To(vm => vm.Stuff) //ViewModel Property

There is also a lot more information on bindings in the Bindings Page in the Wiki.

Upvotes: 3

Related Questions