Fix default values of window properties not being sent to IWindowImpl
#12656
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.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds
TopLevel.CreatePlatformImplBinding
, a lightweight internal binding system betweenTopLevel
and its platform implementation. This makes it easy to set up a relationship which correctly synchronise values, and also reduces the number of property changed observers flying around.What is the current behaviour?
Many window implementation properties are only synchronised when they changed. If the default value of the property is overridden, no change event will be raised and the value of the
TopLevel
and its impl object will be out of sync.The PR includes a test for this scenario.
How was the solution implemented (if it's not obvious)?
My first approach involved static property changed subscriptions, but I quickly found that this required a lot of type casting. I instead opted for a property-to-action dictionary per
TopLevel
instance. This allows much terser lambdas to be written with no type casting at all, and makes it trivial to synchronise the values as each object is constructed.This approach does require regeneration of each callback once per
TopLevel
instance, but given the special nature of the type (sometimes just one instance is created per application lifetime), I don't see that becoming troublesome.Breaking changes
None
Obsoletions / Deprecations
None
Fixed issues
Fixes #11307