I want to binding data(children) from my ViewModel to StackLayout.
In XAML I want something like:
<StackLayout Content="{Binding MainStackLayout}"/>
Is there anyway how to make this?
First of all, a StackLayout has no "Content" property. Now if you want to bind some content inside that would be in form of
<StackLayout Children="{Binding MyChildren}"/>
Your whatever BindingContext (your model) must implement the INotifyPropertyChanged
interface and the variable can look like:
private List<View> _MyChildren;
public List<View> MyChildren
{
get { return _MyChildren; }
set
{
if (_MyChildren != value)
{
_MyChildren = value;
OnPropertyChanged();
}
}
}
public View MainStackLayout { get; set; }
(with property changed method in the setter). – sme