总目录:https://www.v2know.com/MainPage/Category/WPF
为什么说样式设计很重要?
假设你直接在Grid里面创建3个样式完全相同的按钮,
<Grid>
<Button FontSize="20" Foreground="Red" Content="Hello" Width="100" Height="40"/>
<Button FontSize="20" Foreground="Red" Content="Hello" Width="100" Height="40"/>
<Button FontSize="20" Foreground="Red" Content="Hello" Width="100" Height="40"/>
</Grid>
那,这3个按钮应该会出现在同样的位置。
从结论上讲,这3个按钮是相互独立的,当你设置了大小之后,无论如何一般都会居中。
但是你如果放到容器里,这些按钮就会有序排列了:
<Grid>
<StackPanel>
<Button FontSize="20" Foreground="