Why doesn't my GridSplitter appear?

I have a simple Window that looks like this:

 <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()". 

When the application starts, however, GridSplitter not displayed. During development, I also do not see GridSplitter .

  • I made sure the GridSplitter is on the right line and set the VerticalAlignment to Top
  • I specified an explicit background color to make sure that the GridSplitter not blended.
  • I made sure that GridSplitter is the last element in the Grid , so I should not run into ZIndex problems.
  • Just in case, I added fields to the shortcuts to make sure that they do not hide the grid (although in this case it should matter).

What am I doing wrong?

+4
source share
1 answer

You need to set HorizontalAlignment="Stretch" :

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

All Articles