RelativeSource Binding (#4375)
authorPeter Moore <13384523+legistek@users.noreply.github.com>
Tue, 9 Jul 2019 10:10:13 +0000 (05:10 -0500)
committerStephane Delcroix <stephane@delcroix.org>
Tue, 9 Jul 2019 10:10:13 +0000 (12:10 +0200)
commitfa853ff823272af4b307521d4b5774165d1c7e2c
tree3b3d151bbe9b01c7a92691d5839f5d32de1afe6e
parent791d6a6f2257842c30d502d668eb80920763b688
RelativeSource Binding (#4375)

RelativeSource Binding

- fixes #3847

Implement RelativeSource binding modes for Self, TemplatedParent, and FindAncestor. Add unit tests. Pare down TemplateBinding class to use RelativeSource binding mechanism.

* Include RelativeSource member in Binding.Clone

* Fix issue of unit tests being tricked by async in Binding.Apply; permit "Source={RelativeSource...}" in addition to "RelativeSource={RelativeSource..."; allow FindAncestor relative binding source mode to be based on BindingContext type or control type

* Fix unit test wasn't actually testing "Source={RelativeSource...}" syntax.

* Address @StephaneDelcroix's comments. Make FindAncestor relative source binding work even when the ancestor changes.

* Much better mechanism for detecting when a parent changes for relativesource

* Cleanup

* more cleanup

* more cleanup

* Remove async/await for identifying templated parent and ancestor type binding source

* Remove unused code; fix linting

* Update Xamarin.Forms.Core/Binding.cs

Co-Authored-By: Stephane Delcroix <stephane@delcroix.org>
* Update Xamarin.Forms.Core/Binding.cs

Co-Authored-By: Stephane Delcroix <stephane@delcroix.org>
* Update Xamarin.Forms.Core/Binding.cs

Co-Authored-By: Stephane Delcroix <stephane@delcroix.org>
* Update Xamarin.Forms.Core/BindingExpression.cs

Co-Authored-By: Stephane Delcroix <stephane@delcroix.org>
* Update Xamarin.Forms.Core/BindingExpression.cs

Co-Authored-By: Stephane Delcroix <stephane@delcroix.org>
* Update Xamarin.Forms.Core/Binding.cs

Co-Authored-By: Stephane Delcroix <stephane@delcroix.org>
* Ensure TemplateBinding works correctly when reparenting. Cleanup.

* Finish addressing comments; linting cleanup

* Remove private modifier where unneeded
20 files changed:
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Github3847.xaml [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Github3847.xaml.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/PerformanceGallery/PerformanceTrackerTemplate.cs
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Core.UnitTests/ControlTemplateTests.cs
Xamarin.Forms.Core.UnitTests/RelativeSourceBindingTests.cs [new file with mode: 0644]
Xamarin.Forms.Core.UnitTests/Xamarin.Forms.Core.UnitTests.csproj
Xamarin.Forms.Core/Binding.cs
Xamarin.Forms.Core/BindingExpression.cs
Xamarin.Forms.Core/ContentPresenter.cs
Xamarin.Forms.Core/Element.cs
Xamarin.Forms.Core/ElementTemplate.cs
Xamarin.Forms.Core/RelativeBindingSource.cs [new file with mode: 0644]
Xamarin.Forms.Core/RelativeBindingSourceMode.cs [new file with mode: 0644]
Xamarin.Forms.Core/TemplateBinding.cs
Xamarin.Forms.Pages/ListDataPage.cs
Xamarin.Forms.Xaml.UnitTests/Issues/Gh3847.xaml [new file with mode: 0644]
Xamarin.Forms.Xaml.UnitTests/Issues/Gh3847.xaml.cs [new file with mode: 0644]
Xamarin.Forms.Xaml/MarkupExtensions/RelativeSourceExtension.cs [new file with mode: 0644]
Xamarin.Forms.Xaml/MarkupExtensions/TemplateBindingExtension.cs