You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
Color Picker custom style not load on selected pane #4121
This might also be related to the SwitchPresenter as well. Regardless, it should be an easy fix with some update code added to the Loaded event. I'll take a look soon and see where the problem might be occurring though.
Therefore, it's invisible, but still selected maybe? As we wouldn't have updated the default selected item to whatever's left... 🤔
If there is an issue with the SwitchPresenter not reacting to an initial binding change though, let me know. That should be fairly well tested though. But I think this is a SelectedItem issue... May make sense to remove the hard-coded IsSelected and in OnApplyTemplate/Loaded check which options are visible in order and select the first one maybe?
May make sense to remove the hard-coded IsSelected and in OnApplyTemplate/Loaded check which options are visible in order and select the first one maybe?
Yes, I was thinking the same. Will take a look this weekend.
@michael-hawker This issue is partially related to the SwitchPresenter. The ColorPicker code does not handle "tab" selection at all. It instead is designed to rely on selection automatically being updated by the container. This means if a "tab" is set to collapsed visibility the container should figure out it can't be selected and then select the next available "tab". Selecting a collapsed tab simply doesn't make sense and I do think the SwitchPresenter needs to be smarter about this.
That said, this code never worked correctly due to microsoft/microsoft-ui-xaml#2952. As Pivot clearly has a bad design in this area, and we were changing to SwitchPresenter, it was left with the issue at the time.
There are two possible solutions for this:
Make SwitchPresenter smarter and don't allow a collapsed tab to be selected. If the selected tab is collapsed, it will change the selection to the next visible tab. Actually its the new ListBox that is managing selection. I really don't prefer separating selection and content controls like this. TabControl was much better for things like this.
Update the ColorPicker to set tab visibility itself
In the interest of time, I'm going to proceed with option 2. However, if the architecture allows it, I highly recommend updating SwitchPresenter.
Activity
michael-hawker commentedon Jul 20, 2021
FYI @robloo
robloo commentedon Jul 20, 2021
This might also be related to the SwitchPresenter as well. Regardless, it should be an easy fix with some update code added to the Loaded event. I'll take a look soon and see where the problem might be occurring though.
michael-hawker commentedon Jul 23, 2021
Thanks @robloo for taking a look! The
SwitchPresenterbinds to theColorPanelSelectoritem.WindowsCommunityToolkit/Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorPicker.xaml
Lines 95 to 98 in d863f11
So not sure if it's an issue with the SelectedItem being null at first maybe or something else. The
IsSelectedproperty is hard-coded in the style:WindowsCommunityToolkit/Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorPicker.xaml
Lines 80 to 85 in d863f11
Looks like the Visual State toggles the
Visibilityhere:WindowsCommunityToolkit/Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorPicker.xaml
Lines 510 to 514 in d863f11
Therefore, it's invisible, but still selected maybe? As we wouldn't have updated the default selected item to whatever's left... 🤔
If there is an issue with the
SwitchPresenternot reacting to an initial binding change though, let me know. That should be fairly well tested though. But I think this is aSelectedItemissue... May make sense to remove the hard-codedIsSelectedand inOnApplyTemplate/Loadedcheck which options are visible in order and select the first one maybe?robloo commentedon Jul 23, 2021
Yes, I was thinking the same. Will take a look this weekend.
robloo commentedon Jul 26, 2021
@michael-hawker This issue is partially related to the
SwitchPresenter. The ColorPicker code does not handle "tab" selection at all. It instead is designed to rely on selection automatically being updated by the container. This means if a "tab" is set to collapsed visibility the container should figure out it can't be selected and then select the next available "tab". Selecting a collapsed tab simply doesn't make sense and I do think theSwitchPresenterneeds to be smarter about this.That said, this code never worked correctly due to microsoft/microsoft-ui-xaml#2952. As Pivot clearly has a bad design in this area, and we were changing to
SwitchPresenter, it was left with the issue at the time.There are two possible solutions for this:
Make SwitchPresenter smarter and don't allow a collapsed tab to be selected. If the selected tab is collapsed, it will change the selection to the next visible tab.Actually its the new ListBox that is managing selection. I really don't prefer separating selection and content controls like this. TabControl was much better for things like this.In the interest of time, I'm going to proceed with option 2. However, if the architecture allows it, I highly recommend updating
SwitchPresenter.