将WPF控件的大小调整为准确的百分比 [英] Sizing WPF controls to an exact percentage
本文介绍了将WPF控件的大小调整为准确的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在WPF中,我想将控件的宽度设置为其父控件的 ActualWidth
属性的97%.我怎样才能做到这一点?
In WPF, I want set a controls width to be, say, 97% of it's Parent controls ActualWidth
property. How can I do this?
推荐答案
您可以使用网格"面板.例如:
You can use Grid panel. E.g:
<Border>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.97*"/>
<ColumnDefinition Width="0.03*"/>
</Grid.ColumnDefinitions>
<Button Content="97%"/>
<Border Grid.Column="1" Background="Green">
</Border>
</Grid>
</Border>
网格将占据可用边框大小的100%.第一列将使用其中的97%.其余3%在第二栏中显示为边框.
Grid will occupy 100% of available border's size. First column will use 97% of it. And the rest 3% are given to border in the second column.
希望这会有所帮助.
干杯,安瓦卡
这篇关于将WPF控件的大小调整为准确的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文