[英]Gridsplitter not showing
我是WPF的新手。 我聲明我的Grid
是這樣的:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="5"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
</Grid>
我基本上希望寬度為5的第3列是GridSplitter
並且可以為左右列調整大小。 所以我有分配器的代碼:
<GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" Height="Auto"
VerticalAlignment="Stretch" HorizontalAlignment="Center"
Margin="0" Background="Black"/>
我沒有在列中看到GridSplitter
。 我把它設置得對嗎? 謝謝。
GridSplitter以其列為中心,但沒有定義寬度。 因此,您有效地將其寬度設置為零。 它看起來像你有兩個網格,你需要一個。
好像你想要這樣的東西:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" Height="Auto"
Width="5" VerticalAlignment="Stretch" Margin="0" Background="Black"/>
</Grid>
如果需要嵌套網格,則可能需要復制列定義。
我只是運行這個XAML,它工作正常
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="5"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBox Grid.Column="0" MinWidth="100" />
<GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" HorizontalAlignment="Stretch" />
<TextBox Grid.Column="2" MinWidth="100" />
</Grid>
您確定要在第0列中放置三行嗎? 因為它沒有多大意義
而你正在這樣做
<GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Center"
Margin="0" Background="Black"/>
但顯然第一列沒有三行我認為你錯誤地放在第0列。
我想你想要做的就是我寫的第一個XAML
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.