# Color display Error in Panel. Rhino 7 + Rhino 8 С#

**URL:** <https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894>\
**Category:** Rhino Developer\
**Tags:** windows, rhino7\
**Created:** [April 30, 2022, 4:58pm UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894 "2022-04-30T16:58:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [April 30, 2022, 4:58pm UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/1 "2022-04-30T16:58:43Z")

</div>

In Rhino 7 and in Rhino 8 I have an error of color display in the Panel.

 ![fy2](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/8/a/18ae2560547861c2aec7a4b8d92fe67f4fdcfcc6.png)  
 ![fy1](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/a/5/fa51b86a8f25fc7861e5cceb7eb505fc487a54eb.png)  
I think the problem is related to the BackgroundColor assignment in the button 🧐

---

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [April 30, 2022, 6:02pm UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/2 "2022-04-30T18:02:30Z")

</div>

[ToolPaneltest.zip](https://discourse.mcneel.com/uploads/short-url/kngSyTAJ8PwTfP3UwoRzIKGgnxE.zip) (399.3 KB)  
[ToolPanel1.rhp](https://discourse.mcneel.com/uploads/short-url/Kp1xV5GR6Yh4phj5ywFNMhQfbY.rhp) (42 KB)

---

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [May 1, 2022, 7:53am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/3 "2022-05-01T07:53:08Z")

</div>

I think the problem is related to Rhino 7-8. and need a fix for McNeel

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [May 2, 2022, 10:25pm UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/4 "2022-05-02T22:25:12Z")

</div>

Hi @taraskydon,

This is a side effect of the styles we apply to panel controls, by default, so they follow the same color theme, which get applied when your panel is added to the panel host.

There is an API you can use to opt-out of this process:

```auto
Rhino.UI.Controls.RhinoLayout.DisablePanelColorStyling(myControl)

```

which you can apply on a specific control or even the top level panel to opt out of everything.

Hope this helps,

– Dale

---

<div class="post-metadata">

**Author:** ![Christian\_Hartz](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/christian_hartz/32/671954_2.png) [@Christian\_Hartz](https://discourse.mcneel.com/u/Christian_Hartz)\
**Post date:** [May 3, 2022, 6:42am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/5 "2022-05-03T06:42:13Z")

</div>

I had the same issues and as off a discussion with @curtisw I used the same API code @dale suggested. There are two type of call of this method:

```auto
public static void DisablePanelColorStyling(Control etoControl, DisablePanelColorStylingProperty colorProperty)
{
    etoControl?.Properties.Set(DisableColorStylingKey, colorProperty, DisablePanelColorStylingProperty.None);
}

public static void DisablePanelColorStyling(Panel panel)
{
    panel?.Properties.Set(DisableColorStylingKey, DisablePanelColorStylingProperty.All, DisablePanelColorStylingProperty.None);
}

```

The second `DisablePanelColorStyling(Panel panel)` works fine (tested on Version 7 SR17) and applies to all subcontrols in the panel. The first `DisablePanelColorStyling(Control etoControl, DisablePanelColorStylingProperty colorProperty)` seems to have a bug regarding `Rhino.UI.Controls.Divider`. This bug is filed [RH-68508](https://mcneel.myjetbrains.com/youtrack/issue/RH-68508) and @JohnM fixed it and will be available in the next public 7.x release.

Kindest  
Christian

---

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [May 3, 2022, 7:57am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/6 "2022-05-03T07:57:58Z")

</div>

> [@Christian\_Hartz](#):
>
> I had the same issues and as off a discussion with @curtisw I used the same API code @dale suggested. There are two type of call of this method:

Oh. Thank you. I’ll wait for the update.  
Maybe a fix will be added for Rhino.UI.dll 6 Rhino not to make two versions of the plugin. 🙃

---

<div class="post-metadata">

**Author:** ![Christian\_Hartz](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/christian_hartz/32/671954_2.png) [@Christian\_Hartz](https://discourse.mcneel.com/u/Christian_Hartz)\
**Post date:** [May 3, 2022, 7:59am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/7 "2022-05-03T07:59:59Z")

</div>

The fix only applies to the `Rhino.UI.Controls.Divider` control. Any other control seems to work.

---

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [May 3, 2022, 9:21am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/8 "2022-05-03T09:21:53Z")

</div>

The buttons can be cured, but the Expander doesn’t want to be healthy. 😰  
 ![Скриншот 2022-05-03 12](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/b/b/3bb39d7f41d7edf02135e4dc7eeb909aa6a32762.jpeg)  
[SampleCsEtoPanel.cs](https://discourse.mcneel.com/uploads/short-url/Xumir6CSm9kQkwelrT6Eyn5ygk.cs) (2.8 KB)

---

<div class="post-metadata">

**Author:** ![Christian\_Hartz](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/christian_hartz/32/671954_2.png) [@Christian\_Hartz](https://discourse.mcneel.com/u/Christian_Hartz)\
**Post date:** [May 3, 2022, 9:28am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/9 "2022-05-03T09:28:18Z")

</div>

Well what I did:

```auto
/// <summary>
/// Constructor
/// </summary>
public AFPanel(uint documentSerialNumber)
{
    RhinoLayout.DisablePanelColorStyling(this);
    this.ViewModel = new AFPanelViewModel();
    this.DataContext = this.ViewModel;
}

```

That applies to all subcontrols in the `Panel`.

Does that work for you?

---

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [May 3, 2022, 9:46am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/10 "2022-05-03T09:46:31Z")

</div>

[ToolPaneltest.zip](https://discourse.mcneel.com/uploads/short-url/9vekvLgpLv6cSTDsbfxzUHq0IE5.zip) (10.8 MB)

I’m sorry, I don’t know how to fit that in. 😭  
Try in this project. show me. thank you.

---

<div class="post-metadata">

**Author:** ![Christian\_Hartz](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/christian_hartz/32/671954_2.png) [@Christian\_Hartz](https://discourse.mcneel.com/u/Christian_Hartz)\
**Post date:** [May 3, 2022, 9:51am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/11 "2022-05-03T09:51:40Z")

</div>

```auto
using System;
using Eto.Drawing;
using Eto.Forms;
using Rhino.UI;
using Rhino.UI.Controls;
using static Rhino.UI.Controls.RhinoLayout;

namespace SampleCsEto.Views
{
    
    [System.Runtime.InteropServices.Guid("143ae3f7-3b9d-4964-afc3-759de81d029e")]
    public class SampleCsEtoPanel2 : Panel
    {
   
        ToggleButton tV1 = new ToggleButton();
        ToggleButton tL1 = new ToggleButton();
   
        public static System.Guid PanelId => typeof(SampleCsEtoPanel2).GUID;
 
        public SampleCsEtoPanel2(uint documentSerialNumber)
        {
            DisablePanelColorStyling(this); // Try this
            Padding = 0;
            Title = GetType().Name;
            BackgroundColor = Eto.Drawing.Colors.White;

            int stL = 300;
            int stV = 40;

```

---

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [May 3, 2022, 9:56am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/12 "2022-05-03T09:56:58Z")

</div>

> [@Christian\_Hartz](#):
>
> ```auto
> RhinoLayout.DisablePanelColorStyling(this);
> this.ViewModel = new AFPanelViewModel();
> this.DataContext = this.ViewModel;
> 
> ```

Thank you !!! it cured all the components in the panel. 🥰

RhinoLayout.DisablePanelColorStyling(this);

---

<div class="post-metadata">

**Author:** ![taraskydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/taraskydon/32/764889_2.png) [@taraskydon](https://discourse.mcneel.com/u/taraskydon)\
**Post date:** [August 20, 2023, 8:57am UTC](https://discourse.mcneel.com/t/color-display-error-in-panel-rhino-7-rhino-8/141894/14 "2023-08-20T08:57:13Z")

</div>

I accidentally found a way to avoid panel color problems in Rhino 7. without using Rhino.UI.Controls from rhino 7. (RhinoLayout.DisablePanelColorStyling(this)😉 Instead of that I created a fake DynamicLayout. I plugged layout2 into it. I output layout2 into the Panel content.

```auto
 var layout1 = new DynamicLayout { DefaultSpacing = new Size(1, 1), Padding = new Padding(1) };
                var layout2 = new DynamicLayout { DefaultSpacing = new Size(1, 1), Padding = new Padding(1) };
    
                var layoutF = new DynamicLayout { DefaultSpacing = new Size(1, 1), Padding = new Padding(1) };//fake.

                layout1.AddSeparateRow(Add_Folder_button, Folder_Manenger,null);
                layout1.Add(Droptext,false);
                layout1.AddRow(ExportFile_button);

                layout2.BeginHorizontal();
                layout2.AddSeparateRow(layout1, null);
                layout2.Add(scroll, true);
                layout2.EndHorizontal();

                layoutF.Add(layout2);//fake.

        
                Content = layout2;

```

And now the panel for rhino 6 also works on rhino 7-8.
