ColorPicker shows spectrum tab even when disabled and SelectedIndex doesn't work
See original GitHub issueWhen 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:
- Created 8 months ago
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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.