我有以下WPF XAML代码:
<Window x:Class="WPFDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<Button Content="Hello World" Width="Auto" Height="Auto"></Button>
</StackPanel>
</Window>
我已将按钮的宽度和高度设置为“自动”,但仍然会完全横向拉伸。我做错了什么?我不想为宽度和高度提供硬编码的值!