开发者

WPF Panel object placement logic: Is there an algorithm to distribute horizontally-fixed items vertically to prevent overlapping?

Since 'A picture speaks a thousand words', see the picture below for what I'm trying to achieve with my custom Panel in WPF. (unfortunately, since I'm a relatively new user I cannot place an image as such - so characters it is!)

(each 'box' is represented by a number, overlapping area of boxes represented by '-', Time is on the horiztonal from left to right)

I don't want this:

    111111111-----2222222222----------2222222222222222222222222-----22222

I want this:

             222222222222222222222222222222222222222222222222222222222222
    11111111111111          3333333333                         44444

So you can see that I am wanting to displace objects in the vertical to prevent overlapping in the horizontal. So in my example, 'Box 2'开发者_运维问答 has been displace up to prevent a partical overlap with 'Box 1' and entire overlap with boxes '3' and '4'. Just to be clear, I have no problem with the logic for the horizontal (left and width properties) of the objects.

I want to know: Is there is an algorithm that can automatically displace objects in the vertical to prevent this overlapping. (Obviously, I need a general solution that doesn't specifically apply only to my example above.)

Any help would be greatly appreciated.

Ciao, Pete


Have you looked at the WrapPanel? It seems similar to what you want I think.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜