Author Topic: Wpf Palette background is black  (Read 2501 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
Wpf Palette background is black
« on: November 10, 2011, 07:53:29 PM »
I have been playing with custom palettes and seeing what would work with my next hairbrained idea. When I add a winform user control to a palette everything looks as expected, when adding a wpf user control the background is all black. The buttons or whatever I add look fine it's just the background. Here is the code I am using:
Code: [Select]
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows;


namespace Tims_CSharp
    class CustomPalette
        public PaletteSet myPaletteSet;
        public PaletteControl controlPalette;
        public wpfPalControl wpfPalette;

        public void SamplePalette()
            if (myPaletteSet == null)
                myPaletteSet = new PaletteSet("MyPalette", new System.Guid("ABF3806E-DA13-4827-80FB-29D3F10952BE"));
                controlPalette = new PaletteControl();
                wpfPalette = new wpfPalControl();
                myPaletteSet.Add("Custom Palette", controlPalette);
                myPaletteSet.AddVisual("WPF Palette", wpfPalette);
            myPaletteSet.Visible = true;

I am using vs2010 and AutoCAD 2012.
Any ideas why this is happening?

Thanks again,



  • Swamp Rat
  • Posts: 886
  • Certified Prof C3D
Re: Wpf Palette background is black
« Reply #1 on: November 11, 2011, 01:49:04 PM »
Probably because WPF is used in other things like websites, and it has a transparent background by default? If you have a white background in AutoCAD, is the color white then?
Winform objects do have a form background as default I assume, so they are nicely grey.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.


  • Guest
Re: Wpf Palette background is black
« Reply #2 on: November 13, 2011, 04:11:47 PM »
See Kean Walmsley Blog Post:

I did not try the same exact way you are, but the following is what I used from the above post and I did not find any problem with appearance.  The main difference is that the below code uses an elementhost to hold the WPF control on the palette:

Code: [Select]
UserControl1 uc2 = new UserControl1();  //WPF User control
ElementHost host = new ElementHost();
host.AutoSize = true;
host.Dock = DockStyle.Fill;
host.Child = uc2;
_ps.Add("Add ElementHost", host);  //


  • Guest
Re: Wpf Palette background is black
« Reply #3 on: November 13, 2011, 08:20:29 PM »
Huiz - I tried changing AutoCAD's background color. It didn't make any difference.

tonofsteel - that did the trick, thanks.

Steve Hill

  • Mosquito
  • Posts: 5
Re: Wpf Palette background is black
« Reply #4 on: September 09, 2021, 05:15:26 PM »
To follow up on this post, I had the same issue when using WPF as AddVisual() or using ElementHost() as mentioned on the blog post in this feed. Neither worked as transparent background inheriting the default palette color based on the theme light/dark.

I found another solution that sets the palette color to the same as the theme and posted it here: