3

I know that bindings in MvvmCross get hooked up initially when we call SetContentView. However, I am dynamically creating a new view and the bindings from it are not being hooked up. Is there a way to get the MvvmCross bindings to hook up for views created after SetContentView was initially called?

In my example specifically - I am coding for the Google Glass client and implementing multiple cards. When certain information is sent to Glass, I create a new card and inflate an xml file for the new card's view but the bindings are not getting hooked up.

Code to create the new card:

 _cardScrollAdapter.AddItem(LayoutInflater.Inflate(Resource.Layout.new_panel_view, null))

Portion of XML that creates the binding:

local:MvxBind="Bitmap BitmapConverter(PanelViewModel.Image); Visibility Visibility(PanelViewModel.ShowImage)"

1 Answers1

4

The issue is related to the fact that you are passing a View inflated using the Android LayoutInflater.Inflate method, instead of using the MvvmCross BindingInflate method. With a using Cirrious.MvvmCross.Binding.Droid.BindingContext; at the top of your file, the following should work:

_cardScrollAdapter.AddItem(this.BindingInflate(Resource.Layout.media_panel_view,null));
pushasha
  • 769
  • 7
  • 15