0
votes

Does anyone know what's wrong with my code:

<Border Background="AliceBlue" BorderThickness="2">
    <Grid Name="MainGrid" Background="DarkGray" >
        <Grid.RowDefinitions>
            <RowDefinition Height="0.02*"/>
            <RowDefinition Height="0.07*"/>
            <RowDefinition Height="0.63*"/>
            <RowDefinition Height="0.05*"/>
            <RowDefinition Height="0.05*"/>
        </Grid.RowDefinitions>   

        [...SNIP...]

           <StackPanel Grid.Row="2">
            <Expander Header="Filteroptionen" Foreground="WhiteSmoke" FontWeight="Bold">
                <Border Margin="18,10,18,10" Name="border1" CornerRadius="10,10,10,10" Background="Gray" >
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackPanel Margin="15,5,5,5" Grid.Column="0">
                            <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest1">test1</RadioButton>
                            <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest2">test2</RadioButton>
                            <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest3">test3</RadioButton>
                        </StackPanel>
                            <StackPanel Margin="15,5,5,5" Grid.Column="1">
                                <my:DatePicker HorizontalAlignment="Left" Height="25" Name="datePicker1" Width="115" Text="Von" />
                                <my:DatePicker HorizontalAlignment="Left" Height="25" Name="datePicker2" Width="115" Text="Bis" IsEnabled="True" />
                            </StackPanel>
                            <StackPanel Margin="15,5,5,5" Grid.Column="2">
                                <WrapPanel>
                                    <Label FontWeight="Normal" Foreground="White" >Number</Label>
                                    <TextBox FontWeight="Normal" Width="193"></TextBox>
                                </WrapPanel>
                                <WrapPanel>
                                    <Label FontWeight="Normal" Foreground="White" >Name</Label>
                                    <TextBox FontWeight="Normal" Width="250"></TextBox>
                                </WrapPanel>

                            </StackPanel>

                        </Grid>
                </Border>
            </Expander>
                    <Border Margin="18,10,18,10" CornerRadius="10,10,10,10" Background="Gray" >
                        <my:DataGrid Margin="10,10,10,10" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="auto" ItemsSource="{Binding}" Name="mainDataGrid" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" />
                </Border>
            </StackPanel>

I've attached a image here which shows the problem (my scrollbar doesn't show up properly, it gets cut by the grid I think):
Picture

Thanks a lot for any help!

Cheers

2

2 Answers

2
votes

The containing panel's height is not constrained. What is happening is that your containing panel (the StackPanel containing the DataGrid) is growing as large as it needs to be, and thus the DataGrid doesn't think it needs to scroll.

Try setting a Height value on your StackPanel (like the height of the Window, or something similar). The scroll bars should then appear and work.

1
votes

Or, set a MaxHeight on your ScrollViewer, if your container doesn't have a fixed height.