Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

What is BindableProperty.Create( defaultValueCreator: and return new anyone explain how it work?

When control is uses on many pages this dosen't work, that is it cache first used template and use it on all pages:

public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create(nameof(ItemTemplate), typeof(ObservableCollection), typeof(BindableGridView),
new ObservableCollection());

This work fine:
public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create(nameof(ItemTemplate), typeof(ObservableCollection), typeof(BindableGridView),
defaultValueCreator: xx => { return new ObservableCollection(); });

For:
public ObservableCollection ItemTemplate
{
get { return (ObservableCollection)GetValue(ItemTemplateProperty); }
set { SetValue(ItemTemplateProperty, value); }
}

Can anyone explain me why second solution works and why ?

Tagged:

Posts

Sign In or Register to comment.