开发者

Setting height on side-by-side WPF controls

I have two WPF borders, each of which contains some content, which I wish to display side-by-side, and I would like the following height rules to apply:

(1) The height of the control inside the left-hand border will determine the height of both controls. (2) If the height of开发者_开发百科 the control inside the left-hand border is less than 200, then both borders should have a height of 200 (this is a minimum height). (3) If the height of the control inside the left-hand border is greater than 200, then both borders should be set to the height the left-hand border would take if the right-hand border did not exist. The right-hand border will then stretch or be squashed to match what the left-hand border desires.

Is this possible in XAML, or do I have to use some code? And if so, what code would work?

Thanks.


You should bind your right hand border's height to the left one's ActualHeight and set both borders to have a MinHeight of 200

<Border x:Name="leftBorder" MinHeight="200"></Border>
<Border MinHeight="200" Height="{Binding ElementName=leftBorder, Path=ActualHeight}"></Border>


for doing something like this you need a converter which means that you have to use some code . set height of both left and right border to :

Height="{Binding ElementName=leftcontrol,Path=ActualHeight,Converter=developedConverter}" 

and then put your logic for border's heights in the converter body.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜