Conversation

edited

Previously a TemplateBinding just created a normal Binding with a RelativeSourceMode.TemplatedParent. This PR changes TemplateBinding to a simple binding class in its own right, with a Property instead of a Path (note that this is also how TemplateBinding works in WPF and UWP).

Implementing TemplateBinding like this means that for the common case of binding to an AvaloniaProperty on the template parent, no allocations need to be made other than subscribing to a couple of PropertyChanged events: the TemplateBinding class itself is reused for the instantiated binding in the common case that it is bound to a single property.

In WPF and UWP, two-way bindings are not supported by TemplateBinding. Here they are: there was no downside to allowing this and it makes it more broadly usable.

Breaking Changes

Existing TemplateBindings which specify Path= will stop working, as the property is now called Property. Simply remove the Path= qualifier

Existing TemplateBindings which don't simply bind to a property on the templated parent will need to be changed to regular Bindings with RelativeSourceMode.TemplatedParent

Memory Usage

Memory usage was measured via the VS2017 diagnostic tools by running ControlCatalog in Release mode, opening all pages and then taking a memory snapshot:

This comment has been minimized.

edited

Member

This setter was both unnecessary and caused problems in that it was binding to Track.Orientation instead of Slider.Orientation which are actually different AvaloniaPropertys (#1696). This was resulting in the Slider getting messed up.

This comment has been minimized.

Yeah definitely! I looked at using StringTokenizer for this, but it wasn't suitable, and I didn't want to introduce another string tokenizer in this PR. Wasn't sure if we should make StringTokenizer more general purpose, or just manually parse the string here, so I just used Regex for the time being.

Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.