Let's say that I have a grid which has a lot of buttons what I want to achieve is I want to align the button in the top left corner and when I change the size of the window the size of the grid will change and the buttons will be rearranged automatically. My XAML code would be like
<Grid HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Width" Value="100" />
<Setter Property="Height" Value="100" />
</Style>
</Grid.Resources>
<Button Content="Button1" />
<Button Content="Button2" />
<Button Content="Button3" />
<Button Content="Button4" />
<Button Content="Button5" />
<Button Content="Button6" />
</Grid>
I'm a web developer and it's super easy to do it in CSS & HTML.
抱歉,问题很容易,答案是WrapPanel此链接https://docs.microsoft.com/zh-cn/dotnet/framework/wpf/controls/panels-overview对于初学者来说将非常有用
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.