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.