Dan
Dan

Reputation: 13343

Silverlight 3 - Elements inside an element dont arrange sometimes

I have a grid/canvas that has an element (say an icon with an image and text overlayed) added to it dynamically via code.

Most of the time it renders correctly when added (content is aligned properly inside it), but sometimes all the content sits in one corner.

I can remove/add/remove/add/remove/add and it will eventually do it

After a movement of the parent canvas, the element corrects itself as if the layout has been updated.

I have tried the following on Loaded and OnApplyTemplate for both the element and the element parent but it still seems to happen occasionally

Any ideas on why the content wouldn't arrange would be appreciated cause its driving me nuts

Upvotes: 1

Views: 264

Answers (1)

Steve Wortham
Steve Wortham

Reputation: 22230

I'm not sure why it works for you sometimes but not others. But a grid has the inherent ability to dynamically resize itself and its contents. A canvas doesn't (you'd have to handle that manually in code).

If you change your canvas to a grid does it work? A grid has slightly more overhead than a canvas but it sounds to me like you need its functionality anyway.

Upvotes: 1

Related Questions