Marc (34) [Avatar] Offline
#1
Hi,
I'm working my way thru value converters.
I can see:
local:MvxBind="Text Number, Converter=DoubleToString"
local:MvxBind="Text Result, Converter=DoubleToString" />
-rwxr-xr-x@ 1 mfeldman 1063665260 2084 Oct 25 22:44 ./Chapter 11/SquareRt/SquareRt.Droid/Resources/layout/squarert_view.axml


And I can see:
public class DoubleToStringValueConverter : IMvxValueConverter
-rwxr-xr-x@ 1 mfeldman 1063665260 617 Oct 25 22:44 ./Chapter 11/SquareRt/SquareRt.Core/ValueConverters/DoubleToStringValueConverter.cs


What I can not see is how the string "DoubleToString" ends up referencing the class DoubleToStringValueConverter"?
Is that just part of the MvvmCross "magic"? For Android, but not iOS, it slaps "ValueConverter" at the end?

Thank you,
Marc
Jim Bennett (83) [Avatar] Offline
#2
Correct - it is part of the convention based MvvmCross magic, same as it can tie up views and view models using xxxView and xxxViewModel.
Marc (34) [Avatar] Offline
#3
Hi,
Continuing on this thread:
You say "This means we must have a small part of our value conversion in platform-specific code, using value
converters."

1. Which project contains this platform-specific code? .Core or .Droid?


On page 70 the diagram shows what appear to be two classes: BoolToViewStatesValueConverter and BoolToHiddenValuesValueConverter.

2. Although not shown, is it correct that the .axml file for each platform will reference the correct method for the platform?


At the very end of section 3.4.4 you ‘tease’ the reader by mentioning MvxVisibilityValueConverter.

3. How should that class be used? How does it know if it being invoked from Android or iOS specific .axml files? That is, how does it know what kind of values to return?


For this reader, at least, the topic of Value Converters needs a few more words.
If you have the time, please add a complete example of how to control the visibility of a button.

Thx,
Marc