Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
If a bindable property for a type such as a List<T> is created with a default of new List<T>, it seems to re-use the same container object for different unrelated instances of the BindableObject.
The effect here is that if there are 5 BindableObjects declared in XAML and all of them have 1 bindable property of reference type, they all end up have a bindable property with 5 objects, because they all use the same reference object provided in the default parameter.
Created attachment 21899 [details]
Sample to reproduce the issue
ExtendedToolbar is a custom control with a bindable property which is an IList of ToolbarItems.
If the property is declared with a default value, it seems to add 6 toolbar items to each container stacklayout,
whereas if the property is declared with a defaultValueCreator func param, things work as expected.
PS : Please do a restore packages since adding packages subfolder from the project takes it over the attachment size limit.
Thanks for the reproduction project. I will mark this as confirmed until there's further investigation.
Yes, default values are reused.
If you use reference types, you should use the defaultValueCreator delegate instead, that will create a new default value. This is how we do it for, e.g. Grid.ColumnDfinition