-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Refactored Uwp.UI visual extensions #3793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored Uwp.UI visual extensions #3793
Conversation
Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
} | ||
|
||
/// <summary> | ||
/// Identifies the AnchorPointProperty attached property. | ||
/// </summary> | ||
public static readonly DependencyProperty AnchorPointProperty = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just thinking, now that we don't have the explicit registrations, does that mean that bindings won't work with these anymore to update the value???
Looking at it now, I think that's my only concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, just checked as well, this change makes the properties only work with either {x:Bind}
or a static assignment from XAML, but both old bindings and eg. setters in a visual state don't work (I guess the same applies to the title bar extensions too then). Do you want me to reintroduce the properties to keep the support in these scenarios? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not sure if anyone would have been updating these (at least maybe with a VSM) to do some basic options on visuals. Though I know our new animations package provides the ability to make more enriched scenarios, these are in more of a base package helper. So I think supporting more rich expressiveness with them would be important.
Can we kind of mash both worlds together or do we have to keep a backing field effectively to support that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main issue is that all dynamic XAML features such as classic bindings, visual state setters, etc. all just try to match for a DependencyProperty
with the right name for whatever attached property is being used, despite the various getter/setter methods being available. So not really seeing a way to make those work without reintroducing those backing properties unfortunately. We can maybe reduce the overhead just a bit by tweaking the code, removing those unnecessary designer checks etc., but as things stand I don't think we can avoid reintroducing the properties themselves if we want to support these other scenarios 😕
EDIT: as per conversation above, rebased and removed those refactoring for now.
d597e6b
to
8636138
Compare
8636138
to
56e1b46
Compare
PR Type
What kind of change does this PR introduce?
What is the current behavior?
There are two things I noticed in the
VisualExtensions
class:ToVector2/3/4
andToQuaternion
extension methods, which actually targetstring
. Since these types are not really tied toVisual
, and also because these extensions are forstring
, they should be in aStringExtensions
type.SetOffset
,SetScale
etc. that go back and forth to an attached property that stores the value, which then has a handler that simply sets that value in the underlying visual. This adds a ton of overhead due to the multiple indirections and handler invocations, going through theDependencyProperty
backend, etc.. Since we saw that attached properties don't actually need to have a backing property in order to work in XAML (seeTitleBarExtensions
), we can just refactor all of these to simply act as a proxy to theVisual.Foo
properties for the input element. This would make them more efficient and also simpler to implement. It would also remove issues where a property of a visual is changed outside of the extension, so the stored property becomes out of sync with the underlying visual.What is the new behavior?
Applied both fixes mentioned above.
Also optimized the
Vector2/3/4
andQuaternion
parsing extensions:try/catch
and re-throwingAlso adjusted the
ToQuaternion
extension to properly match theQuaternion
constructor that it has.Specifically, there is no constructor that only takes a single
float
, so the parsing should respect that.PR Checklist
Please check if your PR fulfills the following requirements: