-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the problem this feature would solve
BehaviorBase<T> supports a lot of our behaviors but as far as its own API for consumption it feels like I can be refined.
Currently T is constrained to UIElement which is more specific than Behavior<T>'s DependencyObject. So BehaviorBase<T> cannot be associated with any DependencyObject like Behavior making it usable in less scenarios.
On the other hand its behavior from its docs
- Whenever initially fails, this method will subscribe to to allow lazy initialization.
Only works with FrameworkElements but T is constrained to UIElement.
While the behavior
- Prevent duplicate initialization that can happen (prevent multiple OnAttached calls);
will work regardless of the type it feels like constraining T to UIElement is an awkward middle ground.
Describe the solution
Embrace the usefulness outside of the T is FrameworkElement case and make the class usable in more scenarios.
public abstract class BehaviorBase<T> : Behavior<T>
- where T : UIElement
+ where T : DependencyObjector
Embrace the behavior of the T is FrameworkElement case and make the class constrained to scenarios where both 1 and 2 work.
public abstract class BehaviorBase<T> : Behavior<T>
- where T : UIElement
+ where T : FrameworkElementDescribe alternatives you've considered
Do nothing.