.net 基于窗口大小的Wpf按钮宽度

.net 基于窗口大小的Wpf按钮宽度,.net,wpf,.net,Wpf,我有三个按钮的面板。。如下 <stackpanel orientation="Horizontal"> <Button Content="btnone" width="100" height="50"/> <Button Content="btntwo" width="100" height="50"/> <Button Content="btnthree" width="100" height="50"/> </s

我有三个按钮的面板。。如下

 <stackpanel orientation="Horizontal">
    <Button Content="btnone" width="100" height="50"/>
    <Button Content="btntwo" width="100" height="50"/>
    <Button Content="btnthree" width="100" height="50"/>
</stackpanel> 


当我更改窗口大小时,按钮的大小将调整为覆盖整个窗口宽度。。假设当前我的窗口宽度为300。。请帮帮我。

A
Grid
面板可能比
StackPanel
更适合这里。如果我正确理解您的问题,那么这将满足您的要求:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Button Content="One" Grid.Column="0" Height="50" Margin="10"/>
    <Button Content="Two" Grid.Column="1"  Height="50" Margin="10"/>
    <Button Content="Three" Grid.Column="2" Height="50" Margin="10"/>
</Grid>


事实上,我在网格的第一排有stackpanel。。BK@A.Manikandan然后呢?您可以在该行中放置网格,而不是StackPanel。我只是告诉你,如果使用StackPanel,你想要实现的目标会更加困难。我不知道您的整个布局,因为您没有在问题中提供。@A.Manikandan没问题。