Proposal: The Window class should inherit from DependencyObject
Summary
One of the most annoying things about the Window class today, and one that diverges a lot from other XAML frameworks is that the Window class is not a DependencyObject, even though we can declare it in xaml.
It limits a lot of typical use-cases.
Rationale
- Window properties does not support binding, as there's no property bag to store it in.
- Window does not support attached properties to extend how it behave right from xaml (like setting backdrop with helper classes, titlebar settings, manage window stage across app sessions etc).
- You cannot find the Window that a UI Element belongs to, because the root XAML element has the Parent as 'null' instead of Window.
- You cannot use resources to set properties on the window (like theme resources applied to titlebar via helper classes in attached properties).
Scope
| Capability |
Priority |
| This proposal will allow developers to set Window properties through binding |
Must |
| This proposal will allow developers to extend Window behavior in XAML with attached properties |
Must |
| This proposal will allow developers to reach to theme and resource changes at the Window level |
Must |
| This proposal will allow end users to discover which window a given UI element is part of |
Must |
Important Notes
- Window today doesn't have a baseclass, so injecting a baseclass (at least from a .NET point of view) is not a breaking change.
Before: public class Window : ICustomQueryInterface, IWinRTObject, IDynamicInterfaceCastable, IEquatable<Window>
After: public class Window : DependencyObject, ICustomQueryInterface, IWinRTObject, IDynamicInterfaceCastable, IEquatable<Window>
Proposal: The Window class should inherit from DependencyObject
Summary
One of the most annoying things about the Window class today, and one that diverges a lot from other XAML frameworks is that the Window class is not a DependencyObject, even though we can declare it in xaml.
It limits a lot of typical use-cases.
Rationale
Scope
Important Notes
Before:
public class Window : ICustomQueryInterface, IWinRTObject, IDynamicInterfaceCastable, IEquatable<Window>After:
public class Window : DependencyObject, ICustomQueryInterface, IWinRTObject, IDynamicInterfaceCastable, IEquatable<Window>