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

Add key names to default control styles #1300

Merged
merged 5 commits into from
Sep 11, 2019

Conversation

kaiguo
Copy link
Contributor

@kaiguo kaiguo commented Sep 10, 2019

Fixes #1260.

Added key names to default control styles so they can support BasedOn styles like below.

<Style x:Key="MyComboBoxStyle" TargetType="ComboBox" BasedOn="{StaticResource DefaultComboBoxStyle}">
    ...
</Style>

@kaiguo kaiguo requested a review from jevansaks September 10, 2019 01:26
@kaiguo kaiguo requested a review from a team as a code owner September 10, 2019 01:26
@kaiguo kaiguo changed the title Add name to default control styles Add key names to default control styles Sep 10, 2019
<Style TargetType="Button">
<Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}" />

<Style x:Key="DefaultButtonStyle" TargetType="Button">
Copy link
Contributor

@dpaulino dpaulino Sep 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaiguo quick question, would apps that consume WinUI be able to create styles based on these styles?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the idea! If you want to give it a spin you can try the nupkg from the PR build. Try this link?

https://dev.azure.com/ms/_apis/resources/Containers/3023874?itemPath=drop%2FMicrosoft.UI.Xaml.2.3.190910001-prerelease.nupkg

Copy link
Contributor Author

@kaiguo kaiguo Sep 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, apps consuming WinUI should be able to use these styles. The link Jevan posted above has the latest changes, you can give that a try : )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried it and indeed it works! Thanks.

Will there be a docs page or something that lists all the style key names so that we know what key name to put in the BasedOn style property when creating our own styles?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried it and indeed it works! Thanks.

Will there be a docs page or something that lists all the style key names so that we know what key name to put in the BasedOn style property when creating our own styles?

As well as docs, will the Design Time experience allow creating copies of all templates in VS or Blend?

Copy link
Contributor Author

@kaiguo kaiguo Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well as docs, will the Design Time experience allow creating copies of all templates in VS or Blend?

Yes, you should be able to right click the control on design surface and do "Edit Template -> Edit a Copy"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jevansaks who should we ping for doc updates?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just make the changes, but @kikisaints @chigy should recommend which doc we would add it to.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hunch is that it would go here: controls and patterns - buttons under the examples page as a caveat or additional example on how to extend our button control.

Might also be good to mention some of the other styles available for button in generic.xaml, like ButtonRevealStyle..

@chigy for thoughts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kikisaints , are these limited to button? Looks like they could be any control style to BasedOn?

dev/FlipView/FlipView_themeresources.xaml Outdated Show resolved Hide resolved
dev/Pivot/Pivot_themeresources.xaml Outdated Show resolved Hide resolved
dev/Pivot/Pivot_themeresources.xaml Outdated Show resolved Hide resolved
@jevansaks jevansaks added the needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) label Sep 10, 2019
<SolidColorBrush x:Key="FlipViewButtonPointerOverForegroundThemeBrush" Color="#FF000000" />
<SolidColorBrush x:Key="FlipViewButtonPressedBackgroundThemeBrush" Color="#BD292929" />
<SolidColorBrush x:Key="FlipViewButtonPressedBorderThemeBrush" Color="#BD292929" />
<SolidColorBrush x:Key="FlipViewButtonPressedForegroundThemeBrush" Color="#FFFFFFFF" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these brushes using hardcoded values, instead of reusable resources?

<SolidColorBrush x:Key="FlipViewButtonBackgroundThemeBrush" Color="#59D5D5D5" /> 
<SolidColorBrush x:Key="FlipViewButtonBorderThemeBrush" Color="#59D5D5D5" /> 
<SolidColorBrush x:Key="FlipViewButtonForegroundThemeBrush" Color="#99000000" /> 
<SolidColorBrush x:Key="FlipViewButtonPointerOverBackgroundThemeBrush" Color="#F0D7D7D7" /> 
<SolidColorBrush x:Key="FlipViewButtonPointerOverBorderThemeBrush" Color="#9EC1C1C1" /> 
<SolidColorBrush x:Key="FlipViewButtonPointerOverForegroundThemeBrush" Color="#FF000000" /> 
<SolidColorBrush x:Key="FlipViewButtonPressedBackgroundThemeBrush" Color="#BD292929" /> 
<SolidColorBrush x:Key="FlipViewButtonPressedBorderThemeBrush" Color="#BD292929" /> 
<SolidColorBrush x:Key="FlipViewButtonPressedForegroundThemeBrush" Color="#FFFFFFFF" />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, some of them might not be in the theme colors (There's only ~25 system colors https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/xaml-theme-resources#light-and-dark-theme-colors). I agree we should use the reusable resource if there's one available.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got a separate issue discussing that and that isn't the goal of this change so I don't want to dilute this PR with unrelated changes.

@kaiguo kaiguo merged commit e1269c5 into master Sep 11, 2019
@kaiguo kaiguo deleted the user/kaiguo/update-default-style-names branch September 11, 2019 18:49
@jevansaks jevansaks added release note PR that we want to call out in the next release summary and removed needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) labels Sep 11, 2019
jevansaks pushed a commit that referenced this pull request Sep 11, 2019
* Add name to default control styles

* Fix indentation

* Fix test failure

* Update dev/Pivot/Pivot_themeresources.xaml

Co-Authored-By: Chris Glein <[email protected]>

* Update dev/Pivot/Pivot_themeresources.xaml

Co-Authored-By: Chris Glein <[email protected]>
@msft-github-bot
Copy link
Collaborator

🎉Microsoft.UI.Xaml v2.2.190917002 has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Collaborator

🎉Microsoft.UI.Xaml v2.3.191007001-prerelease has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Styling release note PR that we want to call out in the next release summary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ComboBox lost rounded corners if any explicit Style is set for it
9 participants