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

Question: How to do lightweight-styling per style? #4825

Closed
HppZ opened this issue Apr 15, 2021 · 11 comments
Closed

Question: How to do lightweight-styling per style? #4825

HppZ opened this issue Apr 15, 2021 · 11 comments
Labels

Comments

@HppZ
Copy link

HppZ commented Apr 15, 2021

https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/xaml-styles#lightweight-styling
image

@HppZ HppZ added the question label Apr 15, 2021
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Apr 15, 2021
@StephenLPeters
Copy link
Contributor

Style does not have a Resources property. If you are a control author that wants to use the light weight style model for the controls in your library the method to do this is to have your control templates reference well known resources by name using {StaticResource} or {ThemeResource} and then publish the default value for those resources along with your styles. If you are an app author you can interact with the winui2 light weight styling by providing overrides to the well known named resources our templates use. We recommend you do this in your application.Resources within the merged dictionaries of your XamlControlsResources.

<Application.Resources>
controls:XamlControlsResources
controls:XamlControlsResources.MergedDictionaries


....

@StephenLPeters StephenLPeters added area-Resources team-Controls Issue for the Controls team needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Apr 15, 2021
@HppZ
Copy link
Author

HppZ commented Apr 16, 2021

I am an app author, I want to override the well known named resources at Style level, not app level or control level. I need ButtonStyle1, ButtonStyle2, ButtonStyle3 with different overrides. How to do that?

@ghost ghost added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Apr 16, 2021
@mdtauk
Copy link
Contributor

mdtauk commented Apr 16, 2021

I am an app author, I want to override the well known named resources at Style level, not app level or control level. I need ButtonStyle1, ButtonStyle2, ButtonStyle3 with different overrides. How to do that?

Can you use BasedOn to reference an existing Style?

@HppZ
Copy link
Author

HppZ commented Apr 16, 2021

I am an app author, I want to override the well known named resources at Style level, not app level or control level. I need ButtonStyle1, ButtonStyle2, ButtonStyle3 with different overrides. How to do that?

Can you use BasedOn to reference an existing Style?

but how to override Brushs(ButtonBackgroundPointerOver ...) per Style(ButtonStyl1, ButtonStyl2 ...)?

@mdtauk
Copy link
Contributor

mdtauk commented Apr 16, 2021

I am an app author, I want to override the well known named resources at Style level, not app level or control level. I need ButtonStyle1, ButtonStyle2, ButtonStyle3 with different overrides. How to do that?

Can you use BasedOn to reference an existing Style?

but how to override Brushs(ButtonBackgroundPointerOver ...) per Style(ButtonStyl1, ButtonStyl2 ...)?

I don't think you can per Style. You would have to override the style in a page or panel's resources.

@HppZ
Copy link
Author

HppZ commented Apr 16, 2021

I don't think you can per Style. You would have to override the style in a page or panel's resources.

I think it is not flexible so I ask for help here, I thought there is a better way.

@marcelwgn
Copy link
Collaborator

I'm afraid there isn't much you can do or this. Styles don't allow overriding the Resources property so you would have to override the resources on every control.

@mdtauk
Copy link
Contributor

mdtauk commented Apr 16, 2021

I'm afraid there isn't much you can do or this. Styles don't allow overriding the Resources property so you would have to override the resources on every control.

Having said that, Style.Resources sounds like it could be a useful feature for "bundling" up all the light-weight styles associated with a control and it's template.

@marcelwgn
Copy link
Collaborator

I'm afraid there isn't much you can do or this. Styles don't allow overriding the Resources property so you would have to override the resources on every control.

Having said that, Style.Resources sounds like it could be a useful feature for "bundling" up all the light-weight styles associated with a control and it's template.

Yes there should be an there already is a proposal/discussion for this: #3939

@mdtauk
Copy link
Contributor

mdtauk commented Apr 16, 2021

I'm afraid there isn't much you can do or this. Styles don't allow overriding the Resources property so you would have to override the resources on every control.

Having said that, Style.Resources sounds like it could be a useful feature for "bundling" up all the light-weight styles associated with a control and it's template.

Yes there should be an there already is a proposal/discussion for this: #3939

I do remember this being proposed, and I did comment on the proposal - but I didn't connect the two weirdly.

@StephenLPeters
Copy link
Contributor

Yes, today the resource system does not have a notion of resources associated with a style. I do think this could be a valuable addition to the system though.

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants