casillas
casillas

Reputation: 16793

Binding does not work MVVMCross

I have the following implementation where I am getting age and binding it. However, no matter what I did, it did not update on UI and also for some reason it did not even hit the getter.

ViewModel

public void Initialize()
{
   Age = 33;
}

public double _age;  
public double Age
{
  get { return _age ; }
  set
  {
    _age = value;
    RaisePropertyChanged(() => Age);
   }          
}

xml

<TextView
 android:layout_height="wrap_content"
 android:layout_width="wrap_content"
 local:MvxBind="Text Age" />

Upvotes: 1

Views: 957

Answers (1)

Adrian Frielinghaus
Adrian Frielinghaus

Reputation: 668

It's hard to say exactly, without more context. The code looks right. For the binding to work you need to follow the correct naming conventions so that MvvmCross can associate all the necessary bits and pieces with one another. So in this case, if your view is called AgeDisplayView, your view model must be called AgeDisplayViewModel. Your view must also override the OnCreate method and use it to set the ContentView to the layout file that contains the MvxBind instructions (e.g. SetContentView(Resource.Layout.AgeDisplayViewLayout).

That would be the first place I'd look.

Upvotes: 3

Related Questions