-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enabling Fluent as Default System Theme - Next Steps ? #9283
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
Comments
Given the current time constraints, our development window is rapidly closing. I am inclined to opt for "Modify the fluent theme resources and styles to fit in the current system". My rationale is that it's preferable to choose a fully functional option with minor flaws, rather than a more refined but potentially incomplete solution. There's no perfect balance between functionality and resource allocation. My only concern is that this choice might result in legacy issues, making it difficult to modify the framework behavior in the future. Currently, my concerns are as follows:
|
Thanks Dipesh! First of all, I don't think the Fluent theme should become the default theme. It is designed for different kind of apps (with less information density) than what I expect most developers to be using WPF for, and it could hamper the adoption of newer .NET versions. I am open to be convinced otherwise, but I would think we should have a few releases with the theme shipped and perfected before making it default. Second, a theme should be a "proper" theme. Having it in App.xaml as merged dictionary (i.e. "implicitly loaded" above) is not how themes should be shipped or used in production. In addition to the issues discussed above, it changes the precedence of resources for dependency properties. However, I understand that not everything is or will be ready in time for .NET 9 and if we want to keep the new theme "for testing" through next release, I am guessing keeping it as is would continue to serve the purpose. For the technical concerns raised:
That makes me support the "Modify the fluent theme resources and styles to fit in the current system" option. My preference would be:
If there is no time, continue having the theme available for testing and debugging purposes "on the side" for .NET 9, but do not ship any API changes in support of it. |
Lets say I have made an app which I have overridden some colors on some controls for some purpose. Then I just recompile it on .NET 9.0 or whatever and suddenly it has this "fluent theme" which then collided with my changes. I don't think this is a good idea. IF you make breaking changes then it should be something worth it. Like WPF now allows AOT, trimming and what not. (and they're on by default) Then I would be okay with making these changes too. Not because they are necessary but because we are already having huge breaking changes that it won't matter anyways. But we don't have them yet. The only thing we have is this fluent theme which, at the time I was testing it, contains issues. It makes no sense to me to make fluent theme a default theme, at this moment! This is not a technical perspective but a rational. |
Before this discussion moves on, when talking in terms of .NET 9, there will be a switch that will allow the framework to load Fluent as the default theme. I know there are issues with styles and Fluent specific style for all controls is not yet present, so there is no question of Fluent being system theme by default. @miloush @Symbai @lindexi, hope this clears our stand when we are talking about Fluent as default theme. As mentioned above, there are wide differences in the capabilities of both methods. In the current system, there is flexibility of overriding brushes and colors, referencing default styles and creating custom styles and this will setup a precedence that all of these features will be supported in next versions. However, loading as default ( still opt-in ) currently does not support all this, so moving ahead we will be adding functionalities to the theme rather than subtracting them. Loading themes implicitly, i.e. adding the fluent dictionary to app.xaml is always present as a choice to developers to support higher level of customizations. Coming to the API proposals, there are two proposals that we can work on :
|
There is a lot to this discussion: I was expecting you all to ship this with the current method: implicit styles that we have now registered in the app merged dictionaries overriding the theme styles. That said, I have personally encountered the issue of theme styles being used for programmatically created controls and then design inconsistency as the style is forcefully changed. It's not ideal in this way but seems the lesser of two evils (different for all of your assessments above). The reason I say this is the lesser of two evils is simply because we MUST have access to the resources in the fluent styles. There are several custom controls that need to use shared resources (by key) in their control themes. Accent button is one example noted above as well. All of the Fluent v2 theme is designed to work this way and all existing code (even in WPF) is setup to use this. We are going to have a really difficult time moving away from other Fluent theme implementations if we loose this capability here. It's probably going to end up meaning we just copy the theme and register it in merged dictionaries ourselves. As far as dynamic resource usage everywhere, it's required because in modern windows we are expected to be able to dynamically change between light/dark themes. I suppose I would be OK with a mechanism that supports this change only at startup rather than runtime though. Still, ThemeResource in WinUI is looking important right about now. The concern about Fluent NOT being the default theme I somewhat agree with. Most legacy applications are designed for different information density than modern Windows desktop apps. HOWEVER, we have the compact density styles in WinUI to compensate for this. Hopefully that will be carried over here but I haven't dug into the code in that area. Personally, like WinUI/Uno/Avalonia, I would expect a way to choose the theme in the application class at startup. In WinUI2 you could switch between Fluentv1/2 as desired and set the density style. Avalonia also allows registering the theme to use in App.xaml and there are a number of themes available even from 3rd parties. WPF locking this all down for theme styles and registering them behind the scenes was a mistake. There are too many points to address right now but I'm advocating for just using the method we have now:
The ONLY downside I see to this is for programmatically generated elements like popups that might retain Aero2 in some cases. But I consider that the lesser of two evils until the WPF theme system is upgraded to support what we need here (as discussed in the original description). My assumption is we can move to a more integrated design in the future with minimal breaking changes. |
Can you give some examples beside the accented button?
You don't need dynamic resources for that, just two versions of the theme. |
No, I can't share specific code examples. But think of it this way: If you are writing a ColorPicker or other custom control you need to have access to the underlying Fluent theme resources. These resources are consumed by all custom controls to implement their themes that match Fluent. If you are using nothing but stock controls, sure, you can let it all be hidden away. But as soon as you start extending things you need access to the keyed resources. (Please don't recommend duplicated code here too). Edit: Another few cases in an existing app: accent colors need to be customized (user has some ability to adjust themes) and certain in-box control themes are customized too. If you can't have access to the underlying resources (think colors, brushes, etc.) this is a lot more difficult.
That's a lot of duplicated code that is definitely worse in my book that using dynamic resources. If the two themes could be GENERATED from what we have now I would be OK with it. But we are well past the point in time where it makes sense to duplicate code like this. |
I meant examples of resources you think need to be accessible.
Which ones? We have had the current system for years spanning several themes, so it's not like new limitations are being introduced. If you are lacking features, it would be useful to keep track of them.
Sure, that's how it has been for decades now. wpf/src/Microsoft.DotNet.Wpf/src/Themes/XAML/GroupBox.xaml Lines 97 to 138 in 6d26b95
|
@miloush You misunderstand my viewpoint. I have used the existing Fluent v1/v2 themes in UWP/WinUI and am currently using a customized version of ModernWPF that supports Fluentv2. What I am referring to are features that are expected in modern Fluent themes. I'm not referring to features that are in legacy WPF. So when you say "We have had the current system for years spanning several themes" that's true BUT we have all moved past that with third party libraries now. For example, all Fluent2 themes for WPF (third party) have used the dynamic resource approach or some variant that allows switching between light/dark WITHOUT duplicating the entire theme and customizing it for light or dark. What I'm saying is the ecosystem has evolved quite a bit here and the expectations are now different than what was in Aero2. If you take a lot of that functionality away we simply will not be able to use the Fluent2 theme in WPF and will continue using third-party implementations that have the expected functionality. I'm trying to make it possible and more streamlined for those applications that are already using a third-party Fluent2 theme to be able to migrate to the official one here. I'm not going to invest the time digging up all the Fluent2 resource keys we use in custom controls right now. I think I was clear in why it's important to be able to access resources by key:
|
I believe 2. was explicitly stated as undesirable. For 3., the colors and brushes in SystemColors can be overridden, it's only string keys that cannot be looked up. Basically there needs to be a contract between themes and the framework of known resources. To extend the current contract, you need to know which ones are missing for 1.
That makes it difficult to argue a point, I am sure your experiences would be valuable. There is no need to list them all. If you can find a few, especially referencing a Style like in the case of accented button, it would be helpful.
I don't remember that being a goal at any point. People are also free to continue using whatever works for them. What I'm trying to avoid is 1) having two completely separate, incompatible theme systems 2) unnecessary development and maintenance of something that will be obsoleted with next theme 3) significant performance degradation. |
|
Mangling is something that we can control,, earlier it was done for optimization and because developers did not have access to the
We haven't tried this yet.
Regarding the point @miloush said, although loading in app.xaml gives us a great amount of flexibility and even if we continue with the same model, I don't think that is the right places as it disables the scenarios where
For this, I have written a script to combine the resource dictionaries into one, similar to the |
This comment was marked as off-topic.
This comment was marked as off-topic.
@batzen I expected my comment would make you join and reiterate your point, however, I was hoping for some elaboration. What customizations are you looking for? Can anyone give some concrete examples? Otherwise this discussion is hypothetical and no one can suggest how to proceed.
I am assuming the reason the the team went for Fluent theme and stopped doing everything else for a year or two is because it is the most upvoted issue in the repo. Based on comments on the issues (or lack of thereof), barely anyone of the supporters care about customization.
You cannot use string keys. I gave an example how colors and brushes from
What exactly? Using proper theme vs merged dictionary? Or redesigning the theming infrastructure to support string keys and/or dynamic resources? I have not. For some reasons we keep accepting PRs that presumably bring low number of nanoseconds improvements in edge cases, while themes affect every piece of UI in every app all the time. So I want to be careful. I didn't claim either way. Clearly software like Visual Studio managed to do their own theming with performance they find acceptable without using "proper themes", so there are viable alternatives.
@dipeshmsft you don't have to merge the dictionary at an Application level, you can do it at Window or any element level. One thing I haven't said yet is if people are not interested in the existing infrastructure and are happy with the Fluent theme being a separate library with a dictionary to be merged in, e.g. with help of attached properties, and if all the keys needed for customization were defined in that library rather than PresentationFramework, then I have no objections and no concerns. |
can you clarify, default System theme, does it mean some specific OS? Is it about Win 11 only? What would happen if application using this theme will run on Win 10? I'm asking because I wasn't able to install your Fluent demo app on Windows 10 machine |
@IrinaPykhova I believe the intention with the theme being default would only be when run on Win11. |
in this case I don't understand how to properly work with it. You can apply theme and customize something. Then someone will run your application on Win10 and it will look absolutely odd with dated aero2 and your changes made for Win11 |
@miloush Bluntly speaking, have you ever used Fluent2 theme before either in WinUI or one of the 3rd party libraries? I mean actually use it in a production app? You are taking positions I would not expect someone to take who has real-world experience. I've used Fluent2 since UWP/WinUI2 (being part of the discussion before it was released) and also a derivative of ModernWPF -- both in production apps. I've also used and contributed to FluentAvalonia as well. I have years of experience with Fluent2 theme usage in production.
What? You do realize that modification of in-box control themes is a fundamental feature of WPF? You can derive from an existing control, re-template and make it look like a completely different control. This is used all over the place. DO NOT get in the way of application developers delivering on what their designers and management has decided. That is not Microsoft's place and there is always an exception to the rule (you never know what's best for an individual application).
This comment specifically makes me think you've never used Fluent2 before. The theme is designed with a hierarchy of resources. There are the base resources that are then used in the control-specific resources which are then used in the control theme styles. We need full access to at MINIMUM the base resources by string key: wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/Light.xaml Lines 25 to 309 in e1e077d
It seems obvious that needs to be a goal. WPF by Microsoft is VERY late to the game with a Fluent2 theme and most applications have had to switch to 3rd party solutions. You need to learn from those 3rd party solutions and then provide a pathway to bring everyone to the first party theme. You realized this yourself when you based WPF's theme on an existing 3rd party library.
As stated, this indicates you have NEVER used the Fluent theme. The concrete examples are the way the Fluent theme is designed. Again, ALL OF THESE RESOURCES are expected to be used in control resources and then those control resources in the default control styles/templates. wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/Light.xaml Lines 25 to 309 in e1e077d
Edit: And that's saying nothing of the "lightweight styling resource" concept that is used quite a few places. You sometimes need to inject an override to the control resource in the visual tree to change something without re-templating. Again, a pretty fundamental concept with modern XAML and the Fluent2 theme.
String keys are the most important considering how Fluent is designed. If you work with Microsoft I highly, highly suggest you get in contact with the WinUI team to discuss this further internally.
As stated, you can register control styles anywhere in the visual tree. If you don't have an application class register at the window. If you don't have a window, well, you don't need to register styles anyway.
Yes, that's great in that regard. I know it's common to merge individual files into one single Generic.xaml file as well due to not only performance but to avoid circular-references. If there were two separate light/dark (High-contrast, etc. as well) files that could be switched out I would be fine with that. The issue is still no ability to reference the base resources by key for usage in custom controls and re-templating, etc. |
@robert-abeo I am not involved in the theming work and I certainly wouldn't have done that if I was. The team is asking the community on their opinion given their progress and time constraints, you having more experience in this area than others should make it easier to answer questions and argue for your preferences. As I said I have no issues with this continuing to be a mergeable dictionary with resources lookable by string (as long as it doesn't involve diverting API changes). That wasn't one of the two options given, but I am guessing it should be possible, at least for the upcoming release. |
The original post was difficult to understand, so I will provide some general requirements and defer to you and others for the best implementation: Allow us to:
I believe it is important to note that the adoption of WinUI outside of Microsoft is generally quite low, particularly when compared to WPF and WinForms. Therefore, I do not believe it is necessary to align any WPF work with any practices or standards set by WinUI 3. |
I disagree here in that the goal should be to be visually as close as possible to WinUI3 (Fluent for web as well). We should also use the same resource keys (and control template structure) wherever possible. Originally, the plan was to generate as much as possible (even across frameworks) from the same design tokens. Keep in mind a goal of Windows 11 was to unify the UI as much as possible and WinUI3 IS the source of truth for that effort. It is generally harmful for the overall ecosystem to unnecessarily re-invent the wheel especially when there are those of us that have to use multiple XAML frameworks. If there are places where deviation must occur due to different technologies that is understandable (several of these are known already). |
I'm not against consistency with WinUI, where possible. But I don't think the team should spend too many cycles trying to align to something developers do not use or care about. |
Yeah, this seems to be a bind right now, because some of the DWM APIs that we use are only available since build 22621. We are thinking about it in parallel.
It's not like if the resources are loaded as theme ( from here on I will refer it as default ) styles are not stylable. Even earlier, developers could base there custom styles on default styles and modify the properties themselves. Your concern, regarding not being able to use string keys for creating a new custom style is right in its place, this is something that is not present in the current theme infrastructure of WPF, because earlier Windows used to use SystemColors for visual styles and WPF being built at that time followed the same thing.
With recent changes in Windows, I believe there was a shift in design principles and with Fluent coming in things have changed, and no doubt WPF doesn't support the modern ways. We have a lot to cover in terms of themes, styling, the level of customization and flexibility, and we want ( yes, things are moving slowly, I guess slower than what developers have expected so far ) to provide this to our developers, but that also means it will take time. But at the same time, we also need to take care of the systems and compoenents that are in place, and that is why this thread was started in the first place. And that is what @miloush is advocating here. I agree with this point of view. As you mentioned, this is not the long-term solution, and this is my stand as well, because we had to add in checks everywhere ( and I guess we have missed it at places as well ). And since this is not a long-term solution, any changes that come in future may require developers to respond to that, which I believe, will not be a good experience for many developers out there. Surely, default theme as opt-in option is also not the ideal way to do things, but what that does is, it allows us to add flexibility and customizability to the theme in next release.
Yes, obviously we can do that, but that also means we will have to take care of Window, and add a check to see if fluent is loaded in window and allow for dynamic switching. |
The general question is who is the target audience for the introduction of the Fluent styles in WPF? If you ask me it's mainly for the existing WPF applications out there that use the built-in vanilla theming system and not any of the 3rd party theming libraries (i.e. MahApps, ModernWpf, ...). I say so because WPF's theming system is meant to be OS design agnostic with automatically applying a theme that tries to mimic the OS visuals. This is true for XP, Vista/7, 8 (Win10 was sadly ignored since UWP was in focus) and in my opinion should also become true for Win11 with the current effort. (still an opt-in/out may be useful) This means it should work the same way as the previous themes worked without manually referencing it in the <Style Target="Button">
<Setter Property="FontWeight" Value="Bold" />
</Style> as it would apply the Aero2 style button theme. WPF's Fluent styles should look as close as possible to WinUI styles like Fluent UI for web does. I think there is a common ground here. Looking at our time constraints this looks to me like the most reasonable path. It still will take its time until developers actually adopt this new theme. And to mention Win10, I think WPF's Fluent styles should also work on Win10, since WinUI does also work on Win10. |
In either of the scenarios, the way of loading the themes will be optional.
That's in place in the new styles.
We have discarded the use of undocumented DWM APIs and depend on same source as WinUI for accent colors
We are working on this, support for Win 10 is absent currently due to calls to some DWM APIs that are present only in Win11. |
You can override the default styles, yes. But you cannot easily customize them and replace the control template because you don't have access to the base and control-specific color/brush resources (this is what I'm referring to which is the same string key issue). You will have to manually re-create all the control brushes which is undesirable to say the least and not something we have to do with third-party libraries today. It's also not something that has to be done with existing WPF themes because the system colors are always available as you said. Option 1Without the core changes to themes in WPF (to support string key reference lookup, dynamic light/dark switching, compact density, theme switching, etc.) I would say it is a non-starter for us. Reading above where there are others using Fluent themes already that share this viewpoint. There is functionality we absolutely have to have 18 years later. Without that we can't migrate existing code. If I was making the call here I would make the theme fully optional and not fully integrated in .NET 9. I would design it exactly as other third party themes today and require developers to manually register it in the visual tree or app where it's needed. You can provide a reference to the compiled Fluent Generic.xaml and related light/dark resource dictionaries and we can switch it out ourselves manually -- even for individual controls. Deliver what we know already works with maximum control. Yes, that will have to change in the future -- BUT it can be done non-breaking, you just have to keep supporting a hybrid approach. If it takes another year to fully integrate this as a default theme that's fine as far as I'm concerned. Option 2For backwards-compatibility a hybrid approach is probably going to be required long term anyway. That could be done now I suppose. This means you do register Fluent as the default BUT ALSO provide most of the resources in a resource dictionary accessible to apps by string key. Duplicated resources. This seems like a problem now too though because of existing apps that expect Aero. It would eliminate the special casing with certain controls built in code. Option 3Somehow find the resources to make the default themes do what we need before .NET 9. This is bringing the long-term solution forward to the initial release. Based on the issue description I think this would be very difficult. |
I disagree because those apps that are NOT currently using Fluent are those apps that 1) Are so ancient they don't follow latest design conventions anyway or 2) Don't follow Fluent because of issues like information density, etc. If we don't take an approach that works with apps using existing third-party themes today you will cause issues with both classes of users out of the gate. Using the existing 3rd party library techniques means we can quickly bring those apps into the WPF native theme and all other apps that are using ancient styles can continue to not update and be happy. Worse case they do update and then we may only cause trouble for one class of users. Finally, without access to the underlying resource by string key absolutely everyone that attempts to use Fluent and customize it is going to face a challenge -- and they will be vocal about it.
Win8/10 was also ignored because the Metro/WinRT styles in the beginning simply could NOT work with existing desktop apps. They were designed for mobile-sized displays with very little information density -- remember giant rectangle buttons with an icon and cards in a GridView, no corner radius support? Fluent doesn't suffer this problem and works across all platforms. It's actually desktop focused again. I do generally agree that stock WPF should continue the trend of just matching the OS. We are also in agreement on the long-term direction here. We just can't get there due to technical limitations right now. |
No, that's not right. WPF app developers don't use Fluent because they do not have access to the necessary design tokens, styles, resources, APIs, docs, etc. to properly do so. The knowledge is all encoded into WinUI 3 and no where else. MahApps, ModernWpf, etc. are attempts to extract that information but I don't view them as reliable solutions. |
Note that ModernWpf is a direct port from WinUI3. I will expand this to three classes of apps though: Class 1 : Using third party libraries for Fluent already If you force Fluent as the default style you will cause issue for Class 1 and Class 3. Class 2 will encounter problems as soon as they try to customize anything (I guess they don't have experience with Fluent at all yet). If you go with what we have today you don't cause issues by default for any of the classes. Each is optional and we don't face technical issues trying to use the theme. |
After going the discussions, and since each side has there own reasons to back it, I was thinking about enabling both the ways for .NET 9. Obviously, we will have to complete the API proposals before we can do that, but here are the reasons for doing this.
However, at the same time I understand that this can cause more confusion, and when we modify some of the infra that enables this right now, it may not sit well with the developers. I would like to know your views on the above idea. PS : As I mentioned earlier, that API Proposals are crucial here, I would like to have your comments if any on Theme switching (#8932) and AccentColor proposals (#9295). |
A hybrid approach for now makes sense for me. We get Fluent2 by default and also get access to the much needed resources by string key as well. Not being able to access resources was the showstopper (assuming you keep most things DynamicResource still). The only downsides are for class 3 apps (from the list here) that wish to keep using Aero2. However, as discussed above WPF historically has always matched the theme of the system. So it would make sense to continue that. Developers of those apps can continue to use .NET 8 until they are ready to update OR if Theme switching is done by .NET 9 there is no problem here either. Assuming you can stop mangling the resource keys for theme styles in .NET 10 or so the additional implicit styles can go away too. I can't think that would be a breaking change, it would just remove the duplicate resources (and give a little bump in performance perhaps). Hybrid provides a clean path for migration from third party Fluent2 and doesn't have any showstoppers I can think of. I support that direction. |
@robert-abeo Also, there is no mangling of the resource key in the PR above. |
@dipeshmsft I'm confused.
Sounds good.
You seem to undo what you just said 30 minutes before. So I'm not sure why your thinking changed or if I am confusing some point.
Most of the discussion above was based around this point. If we DO NOT have access to resources by string key then we can't use Fluent2. If we DO have access to these resources by string key the majority of my concerns are gone. I was under the impression (along with others) we WERE NOT going to have access to system theme style resources in .NET 9 no matter what. The technical changes just weren't ready. You said:
The only concern remaining is DynamicResource usage.
|
What I meant above was that, in the PR I have added an app context flag to allow loading fluent as default, in future we can have a different mechanism ( maybe something in app.config ) to enable fluent as default and keep Aero2 as default when the correct flags are not used.
The changes ( that allow searching for string resources ) may have other issues. Plus the DynamicResource usage is still something I have not tested out when using Fluent as default i.e. suppose you wanted to update any color or brush, how will it reflect in theme styles. Because theme styles are frozen and cached, currently the static values are realized at the time when styles are loaded.
I still think there is a lot of testing that needs to be done to validate the changes. At the time, when I started this thread, I had done some experiments, and I was getting many issues and the test apps were not working correctly. I think there may be some more issues that I have not hit, but for now, I got the WPF Gallery app working with these changes. |
Have you looked into density styles yet? WinUI handles this case built-in: https://github.com/microsoft/microsoft-ui-xaml/blob/winui3/release/1.6-stable/controls/dev/dll/DensityStyles/Compact.xaml
Ok, that's what I originally understood.
Yes, that is also a concern I noted above. However, it can be worked around with full re-templating. Not ideal but possible. Still, the light-weight styling concept was very useful in WinUI (where you inject a new resource by key directly in the visual tree at the level you want to modify -- without re-templating).
Yes for sure. If you want to just stay with what we have now (implicit styles registered in merged dictionaries) I'm also OK with that. Like I said above it doesn't by default break anyone's use case. It gives another year to make sure things are ready for default Fluent theme styles. |
I will point out it's not "string keys" or "nothing". The assembly with the theme can expose it's resources that can be used as keys for lookup. |
This has been discussed a lot above but I strongly disagree. It is basically "string keys" or "nothing". Without access to string keys you can't customize or use Fluent2 as it was designed. Yes, the app can just copy the entire theme in itself (which I said above we would have to do if you went this route) but that is defeating the purpose of providing a built-in Fluent theme. Why even bother at that point? |
I don't see how that prevents you from customization of the theme. Instead of |
Yes, we can just provide our own color and brush resources, then our own styles and control templates we need to customize. In fact we can just provide our own theme. You are missing the point here. Go use Fluent in real-world apps with WinUI 3. Learn about ThemeResource, the light-weight styling resource concept etc. Then use some WPF 3rd party Fluent theme libraries. With the same features supported by DynamicResource and the same string keys.
I really don't think you understand how Fluent theme is used today and what we have in 3rd party libraries. We need others to jump in on this discussion to break the tie but then we just restart all over again. It's pointless at this point for me to debate this further with you. |
Doesn't have to be static, you could as well do |
Yes, I know you can use DynamicResource as well. But you are missing the forest for the trees. You cannot for some reason see the big picture here. If you were on my team you would be out of the discussion at this point. SystemColors in WPF today is what we have to avoid the above. In Fluent the system colors are built-in as resources. You are essentially saying you can customize Aero2 without SystemColors. That's true but then you have to copy and re-create the entire theme piece-by-piece as needed. Of course the WPF designers thought that was bad practice so provided SystemColors to begin with. Of course we are not going to invest this level of effort either. We will just use another Fluent theme that does what it was designed to do and gives use the resources by default. It's frustrating for me to debate this with you. You fundamentally do not understand my viewpoint and you do not understand Fluent. I will tell you for the last time: If you release Fluent as only built-in system theme styles with all the limitations discussed above it will be unusable for us. Since I have an enormous amount of experience with Fluent you might want to listen to this data point. I'm now stepping out of the discussion. It's not worth my time going in circles like this. |
No I am saying the theme assembly can have its own theme-specific equivalent of SystemColors. |
I've been using WPF for more than 10 years, and I've had a lot of designs and user needs, so I'd like to share the actual development process 1.Win7, I pursue the establishment of acrylic effect, Win10, I pursue the establishment of Mica effect, can only simulate, the effect performance is not good, Win11, WPF is still in place, WinUI 3 sees hope, but can only wait, can not support my project production migration 2.Win7,I pursue Fluent,Win10,I pursue Fluent2,Win11...., yes, all my projects never use the system preset style and color, because whether it is custom or using a third-party Fluent control, I always have to copy and merge all the templates and style keys, including the style of handling light and dark, including the color of the system preset, to ensure that the definition is not repeated
I'm looking forward to WPF Win11 becoming the system preset, and if I can customize it directly with the preset, it will take more than a decade of burden off my mind to focus on functionality and performance optimization In fact, most of the current third-party Fluent controls, I still have to extract some of them and re-customize the style, and I also have to understand how the third-party used was originally defined, and it would be best if WPF could be unified, so that third-party controls can focus on more control extensions, which is also better for the WPF ecosystem I don't have great skills, but I love WPF |
In WPF we have two types of styles for any FrameworkElement - Style and ThemeStyle. Style attribute allows developers to provide custom styles for the controls, whereas ThemeStyle provides a default style which will be used in the absence of custom styles provided by the developer or when developers override only a few properties for the control in the custom style. ThemeStyle ( from here on I will refer to them as default style ) is an internal property and developers don't have access to this property. The default styles are loaded by the framework based on the OS version and color scheme.
As of now, Fluent theme can be loaded by including the resource dictionary in App.xaml, which means that the framework treats them as non-default style and they are loaded in Style property for the framework. Ideally we would want to load them as default styles however, there are some constraints to that approach.
Constraints of making Fluent a theme style
string
. Theme resource dictionaries are only searched for resources when the key is either aType
or aResourceKey
. This will prevent a developer from using resources defined in Fluent theme dictionary. Essentially, that means, we won't be able to access AccentButtonStyle, ControlElevationBrush, etc. by referencing them in custom style as it is possible in WinUI.To deal with the above constraints, we have two options :
We don't face these issues in the current setup ( i.e. fluent theme resources are loaded in app.xaml ). In the current setup, the styles are treated as implicit styles ( when we don't provide a key for a style or we provide the Type as the key, it get's used for all controls without specifying it everywhere ) and we can search for any resource defined in the resource dictionary. Now, when we use this resource dictionary via app.xaml, DynamicResource works as we all know it.
Although the current setup is temporary, and even if we continue with the current setup in .NET 9, it has it's own disadvantages.
Issues with using Fluent as implicitly loaded style
Keeping in mind the time frame for .NET 9 and that we are already past preview 6, getting all the features completed is difficult. So, we would like to seek community opinion on what path shall we take for now.
The text was updated successfully, but these errors were encountered: