C# button长度自动变化
C# button长度自动变化~求助
button初始为100,但随着窗口最大化,button也相应的变化。最好是按同比例增加。
>
<Window.Resources>
<ImageBrush x:Key="BackgroundImageBrush" ImageSource="Resources/background.png" Stretch="UniformToFill" />
</Window.Resources>
<StackPanel HorizontalAlignment="Stretch" Height="550" Margin="10,10,10,10" VerticalAlignment="Top">
<Button Content=" Home " Height="28" MaxWidth="400" HorizontalAlignment="Left" />
</StackPanel>
</Window>
------解决方案--------------------
------解决方案--------------------
宽度是可以设置为百分比的 比如style="width:20%;"
button初始为100,但随着窗口最大化,button也相应的变化。最好是按同比例增加。
>
<Window.Resources>
<ImageBrush x:Key="BackgroundImageBrush" ImageSource="Resources/background.png" Stretch="UniformToFill" />
</Window.Resources>
<StackPanel HorizontalAlignment="Stretch" Height="550" Margin="10,10,10,10" VerticalAlignment="Top">
<Button Content=" Home " Height="28" MaxWidth="400" HorizontalAlignment="Left" />
</StackPanel>
</Window>
------解决方案--------------------
<Window x:Class="MVVM.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="400">
<Grid x:Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.75*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0"></Button>
</Grid>
</Window>
------解决方案--------------------
宽度是可以设置为百分比的 比如style="width:20%;"