Search code examples
mvvmcross

Get MVVMCross Binding from TextView


From the Click event of a TextView\EditText in Xamarin Android I want to get at MVVMCross's Binding instance for that control.

I guess it would be the equivalent of GetBindingExpression in Windows Store SDK

How do I do that?


Solution

  • in MvvmCross, the bindings are stored in the binding context - not in the individual control. This is because the controls aren't natively Data-Binding aware.

    The default context doesn't expose these bindings - see https://github.com/MvvmCross/MvvmCross/blob/bbf9a2ac76e74d9404f4b57036c6e29dfe2cc6c3/Cirrious/Cirrious.MvvmCross.Binding/BindingContext/MvxBindingContext.cs - but you could replace this with your own IMvxBindingContext if you needed to - this implementation could expose "search by control" or other iterator functionality.