Go:Palette Resize

Hi,

I am having some problem on the palette. Basically I want to update the size of the palette whenever I add/remove a node in it. I have a palette in an expander. See hierarchy below:

The palette is based on the controltemplate given here:

But when I load the palette, the height is 0 and no node is shown. but once I collapsed then expand the expander, the content is shown with the correct height. How can I update the size of the palette based on the contents.

Thank you very much for your help.

As that forum topic mentioned, I think you need to specify the size of the Palette.

If you at least specify a particular initial Width, you could try implementing a Diagram.InitialLayoutCompleted event handler that then sets the Palette’s Width and Height based on the Diagram.Panel.DiagramBounds (perhaps scaled, if desired).

How can I get the Diagram.Panel.DiagramBounds?

I set the height to Auto so the size will be based on the content but it is not working. I can’t assign a specific height value because the nodes are not static. The user can add/delete node from the palette.

Did you try what I suggested? Or a Diagram.LayoutCompleted event handler?

I used this:

OtherSnapOnPalette.InitialLayoutCompleted += (s, e) =>
{
OtherSnapOnPalette.Panel.Width = OtherSnapOnPalette.Panel.DiagramBounds.Width;
OtherSnapOnPalette.Panel.Height = OtherSnapOnPalette.Panel.DiagramBounds.Height;
};

The static palettes are working. But the palette where i can add/remove node, the height is not changed. I want to update the height whenever I add/remove node. How can I achieve this?

Use the Diagram.LayoutCompleted event instead of InitialLayoutCompleted

That answers my problem! Thank you very much. :)

Hi,

I have additional question. As I said, I have a palette where I can add/remove node. Is it possible that the layout should only change when I drop the nodes? How can I do that? The current behavior is that when the node entered the palette, it starts computing for the space for the new nodes.

(Answered in http://www.nwoods.com/forum/forum_posts.asp?TID=5840)

Hi,

Just some follow up question regarding this. As I said I used this code to update the initial layout:

Palette.InitialLayoutCompleted += (s, e) =>
{
Palette.Panel.Width = Palette.Panel.DiagramBounds.Width;
Palette.Panel.Height = Palette.Panel.DiagramBounds.Height;
};

This answered my problem on first open of the program. But when I tried to reopen the program, the height of the palette shinked.

1st open: 5 nodes in the palette.
2nd open: 1 node only can fit in the palette.

Note: We are using a cache file.

Thanks. Hoping for your immediate response.

What state is different when you reopen your program?

I would try setting the Palette.Width and .Height, not the Palette.Panel.Width and .Height.