Reputation: 1
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?
Upvotes: 0
Views: 1468
Reputation: 6452
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();
}
}
}
Upvotes: 1