MVVMCross Binding Crashes Android Application

后端 未结 2 1177
慢半拍i
慢半拍i 2021-01-22 08:56

I have an Android App based on Xamarin and MvvmCross. In that application there is a view with an ExpandableListView that I created on my own. Now this list displays several ite

2条回答
  •  庸人自扰
    2021-01-22 09:05

    It's a bit hard to follow the code snippet provided, but I would guess that the problem you are seeing is due to the fact that you are recycling the cell and that each time you recycle it you are:

    • creating a new cell child view,
    • creating a new binding,
    • clearing the old child view
    • but not removing the old binding.

    One way to solve this might be to use the WithClearBindingKey fluent method to allow you to clear these bindings.

    For example, if a binding is created as:

     var set = this.CreateBindingSet();
     set.Bind(text).To(vm => vm.TextValue).WithClearBindingKey("MyDynamicBindings");
     set.Apply();
    

    then just the bindings created with this tag can be cleared using:

     this.ClearBindings("MyDynamicBindings");
    

提交回复
热议问题