Skip to content
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

Proposal: Improve Microsoft.UI.Xaml.Window by Adding Dependency Property Support #10358

Open
ghost1372 opened this issue Feb 15, 2025 · 3 comments
Labels
feature proposal New feature proposal needs-triage Issue needs to be triaged by the area owners

Comments

@ghost1372
Copy link
Contributor

The current Microsoft.UI.Xaml.Window class in WinUI lacks convenience APIs such as Width, Height, and other essential properties that developers commonly use in XAML-based applications. Additionally, Window does not inherit from DependencyObject or UIElement, preventing developers from adding DependencyProperty to it. While simple or full properties can be added, they do not function as expected in XAML at runtime and only work once when the application launches. Given that these limitations have persisted for years, it is crucial to support for DependencyProperty to allow more flexibility in windowing scenarios.

After a few years, the convenience api for window were finally unveiled in v1.7-exp3, but everyone was disappointed. Because access to it was allowed through the AppWindow.

Therefore, it is better to provide a way for creating dependency property. So that developers can easily meet their own needs and not wait months for Disappointing features from Microsoft.

@ghost1372 ghost1372 added the feature proposal New feature proposal label Feb 15, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 15, 2025
@DarranRowe
Copy link

My personal opinion on this is that this will never happen.

Logically, Microsoft.UI.Xaml.Window, which mirrors what is in Windows.UI.Xaml.Window, represents the window that contains the Xaml content. Because of this, Microsoft.UI.Xaml.Window is not a UIElement, it is the container for the root UIElement. I won't say much about DependencyObject, but considering that Window contains the XamlRoot then I am wondering if it could ever work.

@JohnTasler
Copy link

Consider adding attached dependency properties. Create a static class WindowServices or something similar to that.
Since I originally come from a WPF world, I agree that this seems silly that Window does not derive from UIElement, but nobody asked me when they designed UWP's XAML.

@ghost1372
Copy link
Contributor Author

ghost1372 commented Feb 17, 2025

Consider adding attached dependency properties. Create a static class WindowServices or something similar to that.
Since I originally come from a WPF world, I agree that this seems silly that Window does not derive from UIElement, but nobody asked me when they designed UWP's XAML.

you cant even use a AttachedProperty! If you use it you will encounter the following error:

Exception thrown: 'System.InvalidOperationException' in App17.dll
Exception thrown: 'Microsoft.UI.Xaml.Markup.XamlParseException' in WinRT.Runtime.dll
The text associated with this error code could not be found.

Failed to assign to property 'App17.FileName.IsTop'. [Line: 8 Position: 9]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature proposal New feature proposal needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

3 participants