-
Notifications
You must be signed in to change notification settings - Fork 122
Orientation option for Segmented #747
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
base: main
Are you sure you want to change the base?
Orientation option for Segmented #747
Conversation
24309cb to
4d35ca1
Compare
|
@niels9001 was there a reason the indicator was centered under the content only vs. the entire content? That'll only matter in Icon + Text Horizontal mode. |
|
@Avid29 this works perfect! Just slotted right into my VSM with changing the orientation and I was done! 🦙❤️ I'll take a look through the code itself in a bit. |
michael-hawker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty clean to me. @niels9001 @Arlodotexe let me know your thoughts.
| var container = ContainerFromIndex(i) as SegmentedItem; | ||
| if (container is null) | ||
| continue; | ||
|
|
||
| container.UpdateOrientation(Orientation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var container = ContainerFromIndex(i) as SegmentedItem; | |
| if (container is null) | |
| continue; | |
| container.UpdateOrientation(Orientation); | |
| if (ContainerFromIndex(i) is SegmentedItem item) | |
| { | |
| item.UpdateOrientation(Orientation); | |
| } |
Would this be simpler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I have a tendency to over user guard checks...
| using Windows.Media.Devices; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental namespace add?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Visual Studio really just adds whatever as I type and I often forget to even check 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wonder if it's better in VS 2026, I'll have to see as I use it more. It's definitely been a bigger problem in the last year or so than it was in the past.
| RegisterPropertyChangedCallback(SelectedIndexProperty, OnSelectedIndexChanged); | ||
| RegisterPropertyChangedCallback(OrientationProperty, OnSelectedIndexChanged); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to extract the logic in OnSelectedIndexChanged into a SaveInitialIndex method then call it from OnSelectedIndexChanged and OnOrientationChanged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait a minute. That's supposed to call OnOrientationChanged... Yet it does work. Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Because I moved the callback to the DependencyProperty declaration. This line is entirely unnecessary.
Co-authored-by: Andrew KeepCoding <andrewkeepcoding@gmail.com>
|
This is now blocking for #752 |
|
@niels9001 I believe I could get the pill back under the content by finagling the column layout and visual state setters, but as is now I believe it makes the default style's layout more predictable. It might even be simpler if I adjust the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great - and will be really helpful in creating selectable cards or things like a Store-like NavView :)!
Three things that come to mind:
-
Long text labels don't fit.. Maybe we should use texttrimming for this so it just ... for the chars that no longer fit?
-
It feels like we need a bit more spacing vertically (maybe 4 instead of 1) by default to better differentiate what icon belongs to what label. Should we introduce a
HorizontalSegmentedItemSpacingandVerticalSegmentedItemSpacing? -
Have we tested the vertical orientation with the built-in styles too? Could we add an orientation dropdown to this sample too so it's easier to validate any changes in the future?
I looked into it. I'd forgotten that to get the pill to left align properly I had to move it outside of the |
|
Hmm. Yeah, idk what expected behavior is there. You're definitely right that I should add options to more of the samples though. |
I'd noticed this, and looked into that. The issue is |
Co-authored-by: Andrew KeepCoding <andrewkeepcoding@gmail.com>
bb11f05 to
b2bf5af
Compare
|
Sorry @Avid29 I should have merged maybe for the main update vs. rebase as you're working on this. Wanted to pick up the fixes for the tests to be more reliable for the CI. |
|
No problem 👍 |











Fixes #746
PR Type
What kind of change does this PR introduce?
What is the current behavior?
There is not orientation options for the Segmented control
What is the new behavior?
Add customization options for a vertical Segmented control
PR Checklist
Please check if your PR fulfills the following requirements:
Other information