There is a custom Button list in the MyViewModel.
public class MyViewModel : MvxViewModel
{
...
public List<CustomButton> MyButtons;
}
In the Android project, these were added and binded by axml.
<Mvx.MvxLinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
local:MvxBind="ItemsSource MyButtons"
local:MvxItemTemplate="@layout/item_custom_button" />
In the iOS project, I want to place these buttons horizontally on top of the screen and bind them to MyButtons.
But I am not sure how can create these buttons dynamically and bind them.
Any advice?
There isn't a built-in control for iOS similar to MvxLinearLayout
.
This is mainly because iOS has traditionally used pixel perfect layout rather than StackPanel
like effects.
You can implement this yourself by binding a View Property to MyButtons
and then implementing the logic within that property to remove and add the child controls yourself (the layout will be a key part of this - constraints may help here). The MvxView
class may help you here.
Some examples that may particularly help are:
MvxView
in action - see http://slodge.blogspot.co.uk/2013/06/n32-truth-about-viewmodels-starring.html