Proxy or Calculated Property
See original GitHub issueIs your feature request related to a problem? Please describe.
Shortcoming have been discovered in the property system related to dependent properties and properties calculated from others. These same deficiencies existed in WPF so this is nothing new. However, there is an opportunity to solve this better in the future.
Describe the solution you’d like
- Properties that should change and raise property changed events together.
- First noted here by @grokys where
SelectedItem
andSelectedIndex
, if styled properties, have some synchronization issues. - This was apparent after the switch from DirectProperty to StyledProperty. With DirectProperty full control is given in this case to raise events together after both properties are internally handled.
- First noted here by @grokys where
- Properties that alias other properties (proxy)
- This came up in the past to basically support some properties for compatibility with WPF that just alias existing properties with a new type and/or name.
- This includes properties that are calculated directly from another
- For example WPF/WinUI’s
Visibility
property could be an alias ofIsVisible
. - Another example is WPF/WinUI’s
ActualHeight
andActualWidth
property could be an alias ofBounds
. #11325
- Another use-case that was discussed in the past is to allow us to fix API mistakes while keeping compatibility. Currently it is very difficult to rename a Styled/DirectProperty. With such a mechanism we can rename a property then keep an old, obsolete proxy/alias property (with the original name/type) around for compatibility until the next major version.
- https://github.com/AvaloniaUI/Avalonia/pull/6836#pullrequestreview-797475570. “I guess BorderBrush and BorderThickness could be “aliases” for BorderPen.Brush and BorderPen.Thickness but that might raise complications?”
- This came up in the past to basically support some properties for compatibility with WPF that just alias existing properties with a new type and/or name.
Describe alternatives you’ve considered
None, these are issues that haven’t been solved in WPF or WinUI and weren’t fully solved with DirectProperty either.
Additional context Add any other context or screenshots about the feature request here.
Issue Analytics
- State:
- Created 5 months ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Computed Properties — Valtio, makes proxy-state simple for ...
proxy-memoize uses a similar usage-based tracking approach as Valtio's snapshot function, so it will only re-calculate the getter if fields accessed by the ......
Read more >JavaScript Proxy Explained Clearly By Practical Examples
The computed properties are properties whose values are calculated based on values of existing properties.
Read more >Vue.js Proxying
Because Vue takes any data property, method, computed property, etc. and adds a proxy property of the same name at the top level...
Read more >Understanding the Power of Proxy in JavaScript
A Proxy is an object that envelops another object and intercepts basic operations on it, such as accessing, assigning, and deleting properties.
Read more >What does Proxy mean in the console in Vue 3?
a Proxy is an object that encases another object or function and allows you to intercept it. Proxies are stealthy "wrapper" objects which...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rabbitism, The WPF compatibility considerations were an example. There may be other use cases for this concept.
That said, avoiding ambiguity and duplication is important so I see your point there.
I would also add an inherited readonly properties support. Or, readonly styled properties. Use case - ActualThemeVariant, which right now implemented as an inherited property, and technically can be changed by the user (using SetValue directly).
It alternatively can be a computed property as well. But it would require adding some inheritance functionality to the same.