trying to write a new Avalonia Property type #6325
Replies: 2 comments 7 replies
-
|
First of all, DirectProperty is not common type of properties to use. It's recommended to use StyledProperty everywhere, unless you need readonly properties (DirectProperty has it) or has some performance concerns (DirectProperty uses single field to store the value, while StyledProperty uses values store-dictionary with multiple priorities that can be added and removed simultaneously). For the same last reason, you can't set DirectProperty with multiple Avalonia styles. On other hand, that means it's not possible to represent full-featured Avalonia property with single BehaviorSubject, that keeps only one value at a time.
If I were you, and still wanted to implement new property kind, I would go with AvaloniaProperty or AvaloniaProperty. |
Beta Was this translation helpful? Give feedback.
-
Still, I am not sure if it worth the effort, to be honest. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm taking some big stabs in the dark here, but I'm attempting to write a new Avalonia property type, to allow for observable dependency properties. the reason being that I think I can achieve a happier dev experience (less boilerplate) when writing dependency properties by using observables. maybe I'm totally wrong, but won't know without trying :P however, I'm running into trouble implementing this... a combination of barely knowing what I'm doing + I think being blocked by some internal virtual methods...
the code I have so far looks like this:
the idea is to allow a dev to create a BehaviorSubject dependency property in a view, and handle the messy registration via code generation, or some-such (not there yet; again, I barely know what I'm doing here; just playing, at this point.)
a couple questions:
InvokeGetterandInvokeSetter, I assume because they areinternal. I've done inheritance and abstract classes and things many times, but rarely have usedinternal, and rarely while poking so deep at a third-party library I'm still trying to understand :P I guess the question is: am I doing it wrong? is there another way? should I be extendingAvaloniaProperty<TValue>instead ofDirectPropertyBase<TValue>? I feel at a lossBeta Was this translation helpful? Give feedback.
All reactions