gpt4 book ai didi

c# - 为什么我的 GridSplitter 没有出现?

转载 作者:太空狗 更新时间:2023-10-30 00:56:46 25 4
gpt4 key购买 nike

我有一个简单的窗口,如下所示:

<Window x:Class="StackOverflowExample.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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>

<Label Content="Foo" Margin="5" />
<Label Grid.Row="1" Content="Bar" Margin="5" />
<GridSplitter Grid.Row="1" Background="Black" VerticalAlignment="Top" Height="5" />
</Grid>
</Window>

// The code-behind is empty, except for "InitializeComponent()".

但是,当我运行该应用程序时,看不到 GridSplitter。我在设计时也看不到 GridSplitter

  • 我已确保 GridSplitter 位于正确的行中,并将 VerticalAlignment 设置为 Top
  • 我已经指定了明确的背景颜色以确保 GridSplitter 不会混入。
  • 我已经确定 GridSplitterGrid 中的最后一个元素,所以我不应该遇到 ZIndex 问题.
  • 以防万一,我已经为标签添加了边距,以确保它们不会遮挡网格(尽管在这种情况下这应该有所不同)。

我做错了什么?

最佳答案

您需要设置Horizo​​ntalAlignment="Stretch":

<GridSplitter Grid.Row="1" Background="Black" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="5" />

关于c# - 为什么我的 GridSplitter 没有出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6903721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com