Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

wpf - WrapPanel with LastChildFill

I have a set of usercontrols on a data entry form. To allow maximum use of space these usercontrols are placed in a wrappanel that expands vertically. My form works well but it does not look polished visually. I am typing on a mobile device so cannot post a picture but let me describe it.

Say the form has 3 usercontrols demographics (width 800), Phone #s (width 300), Addresses(width 600). The form itself is 1000 pixels wide.

Now when these user controls are laid out(in the order listed above), demographics will be on the top row and the other two usercontrols will be in the row below.

But the demographics control will only ocupy 800 pixels of the available 1000 pixels in the row. And similarly the bottom row will occupy 900 pixels only. That makes the form look ugly.

What I need is to have the last child in each row stretch its bounding bix (ie its border) to occupy remaining space. So in this case demographics' border will stretch to 1000 pixels and addresses' border will stretch to 700 pixels.

the usercontrol collection is dynamic. The user can create new forms on the fly and change elements and their order.

If the screen size changes the stretched elements are restored to their original widths, the wrap panel rearranges the elements and last child in each row fills the remaining space again.

Hope I was able to explain the situation correctly. Thanks for your time.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ended up writing my own custom panel. In the MeasureOverride, jyst before a new line was created, went back to the last processed control and set its length to control.length + (maximumSize- lineSize).

That seems to work well


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...