question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ColorPicker shows spectrum tab even when disabled and SelectedIndex doesn't work

See original GitHub issue

When disabling the Spectrum tab on a ColorPicker it is still shown when the ColorPicker is first opened. Adding the SelectedIndex property to force it onto the Palette tab does not work.

<ColorPicker SelectedIndex="1" IsColorSpectrumVisible="False"/>

After trying several ways to get the Palatte tab to open first time I managed to get it working with reflection and a subclass.

<extensions:ExtendedColorPicker SelectedIndex="1" IsColorSpectrumVisible="False"/>
public class ExtendedColorPicker : ColorPicker, IStyleable {
    
    public Type StyleKey { get; } = typeof(ColorPicker);

    private int selectedTabIndex;
    
    protected override void OnApplyTemplate (TemplateAppliedEventArgs e) {
        // There might be a property set in xaml that get's overridden here
        selectedTabIndex = SelectedIndex;
        base.OnApplyTemplate(e);
    }

    protected override void OnLoaded () {
        base.OnLoaded();
        var type = typeof(ColorView);
        if (type.GetField("_tabControl", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(this) is not TabControl tabControl) return;
        tabControl.SelectedIndex = selectedTabIndex;
    }
}

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 11.0.0-preview4

Issue Analytics

  • State:open
  • Created 8 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SkywardRaycommented, Feb 20, 2023

I’m sorry. I just realized that the project is not visible on Gitlab, I thought I set it to public but it’s not letting me. Here it is on Github instead https://github.com/SkywardRay/AvaloniaTestColorPicker

0reactions
robloocommented, Feb 23, 2023

The more I think about this, I think it might be an issue with the TabControl and best fixed there. The TabControl is literally showing tab content when the tab is hidden. This probably shouldn’t happen and the TabControl itself needs to ensure the SelectedIndex is always valid.

I might change the approach here completely and address this in TabControl.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery Spectrum color picker can't disable
I tried with changes to every Spectrum property or only with the disabled one but it doesn't work. $(document).ready(function() { $('#bg_color') ...
Read more >
WPF Color Picker VS2010 Style
Implementing a WPF Color Picker similar to the Visual Studio 2010 ... When TemplateBinding doesn't work - replace it with regular binding.
Read more >
Microsoft Fluent UI for Shiny Apps
menus will not be in the component tree unless they are being shown. Note: This increases the time the button will take to...
Read more >
ComboBox (JavaFX 8)
An implementation of the ComboBoxBase abstract class for the most common form of ComboBox, where a popup list is shown to users providing...
Read more >
UDN Search
children experiment with color before they even have the manual dexterity to ... color, disabled, open, tabindex, value examples <colorpicker/> attributes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found