-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Introduce the Generic.xaml concept #9612
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Please, make this high priority. Currently, component authors have to resort to ugly hacks to provide some default styles and theming for the controls. |
Bump 👍🏼 Are there any branches this is being worked on that I can follow/experiment with? |
+1 UP |
I don't think we have started any work on this. However, one issue to deal with is the "scanning" part.
However, I think option 2 is a bit better since it is faster for startup and the code can all be generated. @StephaneDelcroix are there any features that we have today that will do things for us or make things easier? Is there a way to hook into the xaml build? |
@mattleibow There are more details in how Generic.xaml worked in WPF "DefaultStyleKey" would be used to look up a "default style" in WPF. Its values would apply with lower precedence than an "implicit style". "ResourceKey" could be created by a control instance for its "DefaultStyleKey", and the "ResourceKey" has an Assembly property. When WPF would lookup Generic.xaml, it will do so in the Assembly specified by that property. That determines which assemblies have to be scanned for "Generic.xaml". The above two features in combination, allowed for Control developers to ship "theme assemblies":
Linker is a bummer, for .NET MAUI it would be awesome if we could still ship multiple assemblies with themes containing Generic.xaml but have them stripped from unused styles after the linking phase. |
Can we expect this for Net 9 version of Maui? |
Description
As a control developer I often write controls that have templates. Templates are great because it allows the developer to overwrite the styles easily. However templating custom controls in MAUI is surprisingly hard compared to WPF, UWP and WinUI.
In those frameworks all you need to do is include a
Themes\Generic.xaml
file with the style, and in each control set theDefaultStyleKey
property. At this point the Generic.xaml styles are automatically loaded and applied to these controls, unless the developer chooses to overwrite these styles. It makes for a very clean story for creating custom control libraries.Public API Changes
Intended Use-Case
As a control developer, I want to build class libraries with custom controls in it, and these controls inherit from TemplatedView. I want to use the XAML editor/designer to define the styles, and I want to make it easy for end developers to also overwrite these styles.
Coming from the other XAML platforms, we're used to do this with the
Generic.xaml
file in theThemes
folder. A similar concept is missing from .NET MAUI.There we're forced to either:
Another great benefit is in Visual Studio I can right-click a control and choose to create a copy of the default style - I'll get the style defined in my app or page based on the original style, and I'll have a good starting point to modify the original template.
The text was updated successfully, but these errors were encountered: