调整大小的窗口时,如何保持stackpanel?
我希望当我最小化窗户时,stackpanel停留在其位置(停留在顶部,不要倒下),而窗户则最小化。
I'm not looking for a direct answer, I just want to find some direction, some help on where to start.
Problem (GIF Format)
XAML Code
<Grid Padding="25">
<NavigationView PaneDisplayMode="Top">
<NavigationView.MenuItems>
<NavigationViewItem Content="Test" IsSelected="False" Icon="PreviewLink" />
</NavigationView.MenuItems>
<Viewbox StretchDirection="Both" Stretch="Uniform" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="1111">
<StackPanel Width="1400" Height="1000" Margin="85, 0, 0, 150">
<Border CornerRadius="25" Background="#1D1D1D" Height="180" Width="300" Margin="-1099, 50, 10, 10">
<Canvas Background="#1D1D1D" Width="250" Height="200" HorizontalAlignment="Left">
<TextBlock FontSize="40" Padding="0, 35, 300, 0" Margin="115, 35, 0, 0" Text="Test"
Foreground="#1D1D1D"
/>
</Canvas>
</Border>
<Border CornerRadius="25" Background="#1D1D1D" Height="180" Width="300" Margin="-420, -190, 10, 10">
<Canvas Opacity="50" Background="#1D1D1D" Width="250" Height="200" HorizontalAlignment="Left">
<TextBlock FontSize="40" Padding="0, 35, 300, 0" Margin="115, 35, 0, 0" Text="Test"
Foreground="#1D1D1D"
/>
</Canvas>
</Border>
<Border CornerRadius="25" Background="#1D1D1D" Height="180" Width="300" Margin="260, -190, 10, 10">
<Canvas Background="#1D1D1D" Width="250" Height="200" HorizontalAlignment="Left">
<TextBlock FontSize="40" Padding="0, 35, 300, 0" Margin="115, 35, 0, 0" Text="Test"
Foreground="#1D1D1D"
/>
</Canvas>
</Border>
<Border CornerRadius="25" Background="#1D1D1D" Height="180" Width="300" Margin="940, -190, 10, 10">
<Canvas Background="#1D1D1D" Width="250" Height="200" HorizontalAlignment="Left">
<TextBlock FontSize="35" Padding="0, 35, 300, 0" Margin="60, 35, 0, 0" Text="Test"
Foreground="#1D1D1D"
/>
</Canvas>
</Border>
</StackPanel>
</Viewbox>
</NavigationView>
</Grid>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题看起来自动调整大小原因,您可以尝试设置
stretch
属性为fill
使StackPanel停留在顶部,但它将制作Canvas
调整窗口大小时,项目形状会更改。另一种方法是通过将
垂直段
设置为顶部的fix ViewBox。The problem looks ViewBox auto resize cause, you could try to set
Stretch
property asFill
to make StackPanel stays on the top, but it will makeCanvas
item shape change when resize the window.The other way is fix ViewBox on the top of parent container by setting up
VerticalAlignment
as top.