如何在wpf中调整窗口大小? [英] How to resize window in wpf?
本文介绍了如何在wpf中调整窗口大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有主窗口分为3个分区。当我调整窗口大小时,左侧和右侧应首先收缩然后收缩。但在我的情况下,首先缩小中央然后左右。
代码贴在下面:
I have main window that divided into 3 partition. When I am resizing window Left side and Right Side should get shrink first then central part. But in my case first shrinking central then right and left.
Code pasted below:
<grid>
<grid.columndefinitions>
<columndefinition width="Auto" />
<columndefinition width="*" />
<columndefinition width="Auto" />
</grid.columndefinitions>
<Label Content="Left Side" Grid.Column="0" />
<gridsplitter horizontalalignment="Left">
VerticalAlignment="Stretch"
Grid.Column="2" ResizeBehavior="PreviousAndNext"
Width="5" removed="#FFBCBCBC"/>
<Label Content="RightSide" Grid.Column="2" />
<Button x:Name="button1" Grid.Column="1" HorizontalAlignment="Stretch" Content="Central"></Button>
</gridsplitter></grid>
请建议。
Please suggest.
推荐答案
Hi Seema,
我希望我理解你的意思......
如果你想要左边和左边的当你重新调整窗口的尺寸时,右侧缩小中央部分,然后你应该使用网格比例,例如:
Hi Seema,
I hope that I understand what you mean...
If you want the left & right sides to shrink more then the central part when you are re-sizing the window to be smaller, then you should use Grid proportions for example:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Left Side" Grid.Column="0" />
<GridSplitter HorizontalAlignment="Left"
VerticalAlignment="Stretch"
Grid.Column="2" ResizeBehavior="PreviousAndNext"
Width="5"/>
<Button x:Name="button1" Grid.Column="1" HorizontalAlignment="Stretch" Content="Central"/>
<Label Content="RightSide" Grid.Column="2" />
</Grid>
中间部分是窗口的10/12,而左边和右边是右边只有窗口的1/12。
The middle part is 10/12 of the window, while the left & right are only 1/12 of the window.
这篇关于如何在wpf中调整窗口大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文