Skip to content

Fix workaround in Segmented control #699

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndrewKeepCoding
Copy link

This commit modifies the OnApplyTemplate method in the Segmented class to set SelectedIndex to -1 and then assign _internalSelectedIndex if _hasLoaded is false. This ensures the selected index is reset before applying the internal selection and marks the template as loaded.

Fixes

#698

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

The selected item is not rendered as selected when in XAML:

  • 2 SegmentedItems are declared
    and
  • SelectedIndex is set to 1.
<toolkit:Segmented SelectedIndex="1">
    <toolkit:SegmentedItem Content="Item 1" />
    <toolkit:SegmentedItem Content="Item 2" />
</toolkit:Segmented>

image

What is the new behavior?

The selected item is rendered as expected.
image

PR Checklist

Please check if your PR fulfills the following requirements:

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • Contains NO breaking changes

Other information

… template application

This commit modifies the `OnApplyTemplate` method in the `Segmented` class to set `SelectedIndex` to `-1` and then assign `_internalSelectedIndex` if `_hasLoaded` is false. This ensures the selected index is reset before applying the internal selection and marks the template as loaded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant