Atook you got me wrong. I am talking about a whole UserControl not a single control in a UserControl. To clarify please check the code below ;
private static PaletteSet paletteSet;
private static Palette palette;
private static UserControl1 userControl;
public PaletteDemo() //this is constructor
{
if (paletteSet== null)
{
paletteSet= new PaletteSet("MyPaletteSet", new Guid("81BE7D63-5FA9-4CA5-9418-7830CA53B766"));
paletteSet.Dock = DockSides.None;
paletteSet.DockEnabled = DockSides.None;
}
if (userControl== null)
{
userControl = new UserControl1();
}
}
[CommandMethod("AttachPalette")]
public void AttachPalette()
{
if (palette== null)
{
palette = paletteSet.Add("Control1", userControl);
}
paletteSet.Visible = true;
}
[CommandMethod("DetachPalette")]
public void DetachPalette()
{
if (palette != null)
{
int i = 0;
for (i = 0; i < paletteSet.Count; i++)
{
if (paletteSet[i].Name == "Control1")
{
break;
}
}
if (i != paletteSet.Count)
{
paletteSet.Remove(i);
palette = null;
}
}
if (paletteSet.Count == 0)
{
paletteSet.Visible = false;
}
}
after loading this code with netload and type the commands:
AttachPalette //No problem shows the PaletteSet with the Palette hosting UserControl1
DetachPalette //No problem hides the PaletteSet
AttachPalette //Problem. Showing an empty PaletteSet