Binding to Parent and Grandparent? [duplicate]

2019-02-26 06:49发布

问题:

This question already has an answer here:

  • MvvmCross: Bindings for Android 1 answer

How would I bind to a grandparent in MVVMCross?

I have a List<string> which I'm binding to a MvxLinearLayout with its own item template "A". When the user clicks on the button in "A" I would like to fire an ICommand in its parent (i.e. the owner of the List<string>).

I also have a similar situation with a grandparent relation.

How would I do this?

回答1:

There is no parent binding access in lists or any other mvx data binding context currently.

There are plenty of simple workarounds - see questions such as MvvmCross Android - Alternative to RelativeSource binding for button command for some suggestions.


I've answered questions similar to this several times. Each time i invite people to raise feature requests, ideas or pulls to issues such as https://github.com/slodge/MvvmCross/issues/35 . While there have been perhaps 3 or 4 of these questions, no-one ever seems bothered enough to follow up, so i guess it's not an important feature.