-
Notifications
You must be signed in to change notification settings - Fork 703
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
Proposal: lightweight styling for NavigationView top button spacing #1961
Comments
I would like to try fixing this. My current thinking is to introduce at least the following resources (and potentially more as I further look into NavigationView, such as OverflowButton/Header/AutoSuggestBox margin resources): <!--NavigationViewItem margins for NavigationView DisplayMode Top & Left-->
<Thickness x:Key="TopNavigationViewItemMargin">0</Thickness>
<Thickness x:Key="NavigationViewItemMargin">0</Thickness>
<!--NavigationViewItemSeparator margins for NavigationView DisplayMode Top & Left-->
<Thickness x:Key="TopNavigationViewItemSeparatorMargin">10,0</Thickness>
<Thickness x:Key="NavigationViewItemSeparatorMargin">16,10</Thickness>
<!--NavigationViewItemSettings margins for NavigationView DisplayMode Top & Left-->
<Thickness x:Key="TopNavigationViewItemSettingsMargin">0</Thickness>
<Thickness x:Key="NavigationViewItemSettingsMargin">0</Thickness> As such, this would also minimally cover #2139. Thus, if adding resources for easier NavigationView theming is desired and @ojhad is not working on adding them already, I would like to look into this. |
Thank you, @Felix-Dev, this approach sounds great. |
@YuliKl I currently settled on the following theme resources to introduce with a PR for this issue:
I would also like to add the following theme resource:
I separated this theme resource from the ones above as the addition of this one would be a UI breaking change. Currently, the margin of the While I do think the lightweight customization options for the margin of the NavigationViewItemHeader should be improved as outlined above, this won't be absolutely necessary here in a PR covering this issue. The Alongside PR #2206 which enables lightweight customization of the NavigationViewItemSeparator margin these new theme resources will provide ample flexibility to customers to customize the margins of the NavigationView pane elements in top mode. |
@YuliKl Friendly ping. |
I'm definitely in favor of adding the first four resources you suggested:
I feel less good about TopNavigationViewItemHeaderInnerMargin. I can't dispute your observation that
because it introduces dead weight, and breaks any existing customization - app developers would need to notice that the resource is no longer in use and change their code to customize a differently named resource. So I would recommend omitting this last change from a PR. |
I do hope that at some point we can use semantic versioning to look at all these theme resources which are currently lacking precision or are incorrectly named so that we can make these breaking changes (by just removing outdated or incorrectly named theme resources) at some point in the future.
It seems to me as if the team is looking at this on a case-by-case basis as we had cases like these where we were left with now unsued theme resources. It was decided to keep them for now so that we won't cause apps to crash at runtime (in the slight chance they are using theme resources in a way which would lead the app to crash). This leads back to my first remark - hoping that at some point for some WinUI verison, we can look at this holistically for WinUI and accept the possibly generated "developer pain" to provide a consistent and well-named lightweight-styling experience. So to conclude: Does that sound ok to you, @YuliKl? |
Thank you, @Felix-Dev, this sounds good. @MikeHillberg - do you have any thoughts about the unused or misnamed theme resources, and when an opportune time may present itself to clean things up? |
From my understanding WinUI 4.0 if we stick to semver. |
Proposal: lightweight styling for
NavigationView
top button spacingThis issue is a follow up from a conversation we've had with some WinUI engineers and other developers over at the UWP Community discord server, specifically the thread starting with this message.
Summary
Allow developers to customize the spacing of the buttons in the
NavigationView
in top navigation mode through lightweight styling (by overriding a specific resource that's used in the template), instead of forcing them to use explicit code that interacts with the visual tree directly.This results in an easier experience for developers, which is also more portable and less error prone (and with the additional benefit of requiring no code behind trickery).
Additional info
I'm trying to create the following look for buttons in the
NavigationView
, with a 2px spacing:This is different from the default look, which uses no spacing at all, which I personally don't like for stacked buttons with the reveal highlight effect:
The template for the
NavigationView
is here, and I've linked the area reserved to the top buttons. As you can see, theItemsRepeater
is not using any resource to set theSpacing
property, making it impossible to use lightweight styling for this. Furthermore, the "More" button doesn't have spacing either, forcing users to also manually set some left margin there to keep the look consistent with the buttons. Here's the code I'm using right now, under aLoaded
handler for theNavigationView
:This is not really ideal, for obvious reasons. It'd be nice to be able to set the spacing for both buttons with a simple resource that can be overridden with some lightweight styling.
Rationale
Scope
Open Questions
Not really related, but...
Why is the "More" button lacking the reveal highlight completely?
See here:
I think it should use the same exact visual style as the other top navigation buttons.
The text was updated successfully, but these errors were encountered: