Understanding the data-binding syntax
Override the ViewDidLoad
method in the FirstView.cs
by the following code:
MvvmCross
use the fluent syntax to implement data-binding for iOS. First, MvvmCross
creates the relationship between the View and the ViewModel
by this code:
Then you can set the data-binding by For
and To
methods:
If For is not provided, MvvmCross
will set the default view property. For example, the Text
property will be used for a Label
control. For more default view properties information, check this document here: https://www.mvvmcross.com/documentation/fundamentals/data-binding.
With the fluent syntax we can continue to specify the binding type, such as OneWay
, and TwoWay
, etc, like this:
At last, DO NOT forget to call the Apply
method to apply the data-binding:
We can build and launch the iOS project now. Here is the result:
Last updated