1
votes

I have a Grid inside a Grid

<Grid Style="{StaticResource GridMinWidthEditStyle}" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=ActualWidth}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <TextBlock Grid.Row="0" Text="xxx" Style="xxx"/>
    <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" PanningMode="VerticalOnly">
        <Grid  Background="{StaticResource LightBackground}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
        </Grid>
    </ScrollViewer>
</Grid>

I set my scrollviewer around the inner Grid, but i want it around the outer grid. the problem is that my vertical scrollbar is over my content at the side, and a horizontal scrollbar is added too.

1

1 Answers

4
votes

Scrollbar comes over my content again at the right

, but I have found a solution that works foe the rest.

The Scrollviewer and outer grid needs the width property instead of the outer grid. The outer Grid needs the Style (MinWidth)

<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" PanningMode="VerticalOnly" 
    Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=ActualWidth}">
    <Grid Style="{StaticResource GridMinWidthEditStyle}" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=ActualWidth}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <TextBlock Grid.Row="0" Text="xxx" Style="xxx"/>
        <Grid  Background="{StaticResource LightBackground}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
        </Grid>
    </Grid>
</ScrollViewer>