Replies: 12 comments
-
Great idea, would love to be able to set the resources in style and not otherwise. This would probably also make it a lot easier to create new styles/facets of a button, especially when thinking about design tokens (@mdtauk this might be interesting for you). |
Beta Was this translation helpful? Give feedback.
-
I read the blog post when it first went up, and then noticed Rudy's Twitter response, and noted the blog post was updated. I can't say I have my head around it tbh, and as light weight styling is still relatively new for Xaml as an approach, I can't speak to the long term affects it may have. Anything that makes styling controls easy is a good thing. When I was first designing controls back in the WP7 days, I tended to add every visual property I could ever want to customise as control dependency properties. So I could, on Xaml, set every colour, icon, text style etc and have every element in the control templates, collapsing and using visual styles to choose the layout. Now obviously that leads to a heavy control but has lots of customisation options. So if I am not understanding this I apologise, but the things that come to mind are:
|
Beta Was this translation helpful? Give feedback.
-
Good question, this wouldn't really change how we expose lightweight styling resources. This would only make it easier to override them in style instead of defining your new resources globally or on a per instance basis.
I would assume that the ResourceDictionary would apply to every instance that uses that style. This would be equivalent to setting the resources property of the control.
I hope so, but this would depend on the VS integration.
Well you could have a different style for every set of tokens which only overrides the specific theme resources and are based on your default style. Having a ghost button style for example would be just a style with a resourecdictionary changing the specific colors.
I don't see why it shouldn't. This should become a XAML language feature in my opinion (WinUI 3.X++). |
Beta Was this translation helpful? Give feedback.
-
I think this is a problem that will need to be solved in time, and Lightweight Styles and StyleResources should be formalised in the SDK so Intellisense can provide a list of all the lightweight resources the Control has, and provide autocomplete, as well as property grid entries for viewing and changing them. So almost treating them as if they are dependency properties. Maybe this could be some kind of grouped tag element in the ResourceDictionary itself? <ControlStyleResources TargetType="Button" Name="UglyButton">
<SolidColorBrush Name="ButtonForegroundTextFillColorBrush" Value="Pink"/>
<SolidColorBrush Name="ButtonBackgroundTextFillColorBrush" Value="Plum"/>
</ControlStyleResources>
So this would always be at a control level? If I had a StackPanel of Buttons, and put my lightweight Background Colour resource in the
Might be worth talking to the SDK team about including designer and property inspector support for these, and work towards formalising these as part of a wider upgrade to Xaml Styling.
Wouldn't the Figma plugin being developed, need to take into account these new StyleResources, for when a UI designer wants to call out a specific button, or a specific group of buttons, using a non-default set of colours/sizes etc? |
Beta Was this translation helpful? Give feedback.
-
This definitely sounds like an interesting idea. How would this differ from the regular resources though? Do I have to use every resource in there? My concern is that this might make getting started with XAML even more difficult as it already is.
Yes, the support should be better for these kind of things.
Not entirely sure how this would work as I'm not really familiar how that plugin will work, however I would assume that that would be possible. |
Beta Was this translation helpful? Give feedback.
-
Because lightweight styling is just using Resources listed in the Resource/Theme Dictionaries - there is no way I know of, for Intellisense and the Designer to know which of these is currently used/intended to be used by the control. My thinking is that by putting them into a group, with a psudo code function
I also am in the dark somewhat about the Plugin, beyond it seemingly acting like the Fluent Theme Editor with it's settings - and that it outputs CSS and XAML which gets imported into your app code. But I mention it, as if this is added either in WinUI or as a Language feature - the people working on the Pipeline may need to make allowances for it, to make use of it, or to support the same Lightweight styling |
Beta Was this translation helpful? Give feedback.
-
You could scan inside the template the resource dictionary is in if it's used in there or not, but that is only a partial solution here.
I like the idea, but the issue I see is that we introduce even more classes and concepts to the XAML world. And when should you use those new resourcedictionaries over a style? My guess would be that the general developer guidance would be "just use a style with resources set" since at some you might need to change more than lightweightstyling resources (e.g. adjust margin) and then you need to switch anyway.
Got it. Very good idea of bringing that up here, this should definitely be though about if this proposal will be implemented! |
Beta Was this translation helpful? Give feedback.
-
The solution should always be to make the IDE/Intellisense/Autocomplete/SDK smarter - rather than adding things to try to hint or help. If there is a way for the Designer and IDE to surface these lightweight styles for the developers - this would be preferable. Even adding a comment or a XAML Region around the lightweight style resources, to help the tooling expose these, would be preferable. |
Beta Was this translation helpful? Give feedback.
-
any update? |
Beta Was this translation helpful? Give feedback.
-
Add my name to the list of those disenfranchised by lack of |
Beta Was this translation helpful? Give feedback.
-
In my case I used |
Beta Was this translation helpful? Give feedback.
-
I was expected this to work but it seems like not. Definitely would use this. |
Beta Was this translation helpful? Give feedback.
-
Discussion: Add a new Style.Resources property to simplify Lightweight Styling.
It would be nice we could add a Resources property to the Style class. It would allow you to define the Resources for this Style. This would simplify Lightweight Styling.
Setting the Resources in a Style.Setter isn't possible because it isn't a Dependency Property. See error message:
There is a workaround which I documented in my XAML Lightweight styling done right blog. It involves a custom Attached Property and a ResourceDictionaryCloner helper class (stolen from @rudyhuyn). @rudyhuyn has published a XamlPlus project with a similar (better) solution for this.
This workaround is a bit awkward and with a Style.Resources property it wouldn't be necessary. I hope you agree. Let's discuss this.
Related Links
Beta Was this translation helpful? Give feedback.
All reactions