Marc (34) [Avatar] Offline
#1
Hi,
Its interesting: The more details you learn, the less sense the initial simplifications make.
Take binding as an example.
You say, in several places, that the MvvmCross binding layer uses reflection to find "the" property.
For example:
local:MvxBind="Text Name" />

Question:
If I have multiple classes, each of which has a Name property, how does the MvvmCross binder know which class I'm referring to?
Must all public property names be unique across the whole project?
Can the reference from the layout (axml file) include the class?
local:MvxBind="Text Parent.Name" />

Thx,
M.

Jim Bennett (87) [Avatar] Offline
#2
The property comes from the binding context - so the view model. If you navigate to the FooViewModel, the FooView is shown, using an instance of the FooViewModel as it's blinding context. It's a property called
Name
on this view model that is used.

You can have multiple view models with properties with the same name, the view will only use the one from the view model for that view. So if you had a BarViewModel with a Name property, that would only be used by a binding to Name on the BarView.

This loose coupling is actually pretty useful - the binding is to a property with that name on the binding context, so you can have a custom control that binds to Name. If this control is on a FooView it would use the Name from the FooViewModel, but if the control is on a BarView then it will use the one from the BarViewModel.