2015-01-19 2 views
0

У меня есть сетки внутри сеткиWPF Xaml ScrollViewer вокруг сетки в сетке

<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> 

Я установил мой ScrollViewer вокруг внутренней сетки, но я хочу его вокруг внешней сетки. проблема в том, что моя вертикальная полоса прокрутки находится над моим контентом сбоку, а также добавлена ​​горизонтальная полоса прокрутки.

ответ

3

Scrollbar приходит мое содержание снова в правой

, но я нашел решение, которое работает враг остальное.

Scrollviewer и внешняя сетка нуждаются в свойстве width вместо внешней сетки. Наружная Сетка нуждается Стиль (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> 
+0

У меня была проблема с многострочных текстовых полей, так что мне нужно, чтобы добавить свойство ширины и для внешней сети. (текстовое поле отсутствует) –

Смежные вопросы