Introduce the Generic.xaml concept
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 296
Description
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 the DefaultStyleKey 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
public class MyControl : TemplatedView
{
public MyControl()
{
DefaultStyleKey = typeof(MyControl);
}
}
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 the Themes folder. A similar concept is missing from .NET MAUI.
There we're forced to either:
- manually load it in the constructor from a string (slow) example
- ask the end user to add a resource dictionary to their application (error-prone / cumbersome)
- On-the-fly insert our own resource dictionary into the application resources, which is error prone (could be added in the wrong order and override user-defined styles, and it feels wrong for a control to be modifying application resources). example - literally called a hack
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.

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed TemplatedView API, DefaultStyleKey usage, and the Themes\Generic.xaml convention described in the issue, then compare how WPF, UWP, and WinUI load and override default styles. Done should provide a Generic.xaml-based default style mechanism for custom controls while allowing application or page styles to override it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100