我希望當我最小化視窗時,StackPanel 在視窗最小化時保持在其位置(保持在頂部,不要在下面)。
我不是在尋找直接的答案,我只是想找到一些方向,從哪里開始提供一些幫助。
問題(GIF 格式)
問題的 GIF
XAML 代碼
<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>
uj5u.com熱心網友回復:
StackPanel 在視窗最小化時保持在其位置(保持在頂部,不要向下)。
問題看起來是ViewBox自動調整大小的原因,您可以嘗試將Stretch屬性設定為Fill使 StackPanel 保持在頂部,但它會Canvas在調整視窗大小時使專案形狀發生變化。
另一種方法是通過設定VerticalAlignment為頂部將 ViewBox 固定在父容器的頂部。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/494041.html
上一篇:多種字典型別的C#切換型別
下一篇:泛型陣列的c#擴展方法
