Question

I'm working from some Microsoft Sample Code and it appears to have a ScrollViewer in it that does not appear to work as intended (or how I would expect and want it to).

<common:LayoutAwarePage 
x:Class="ControlChannelHttpClient.Scenario1" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:ControlChannelHttpClient" 
xmlns:common="using:SDKTemplate.Common" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d"> 

<Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Left" VerticalAlignment="Top"> 
    <Grid.RowDefinitions> 
        <RowDefinition Height="Auto"/> 
        <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 
    <Grid x:Name="Input" Grid.Row="0"> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="Auto"/> 
            <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 
        <StackPanel Margin="0"> 
            <TextBlock TextWrapping="Wrap" Style="{StaticResource BasicTextStyle}"> 
            This scenario demonstrates how to use the ControlChannelTrigger object with HttpClient. 
            This app demonstrates an HTTP client. A server is provided with this sample. 
            The client and server must be deployed on separate machines. Once the server is set up, 
            the client can set up the ControlChannelTrigger with the HttpClient by clicking Connect. 
            This sends an HTTP request to the server. Note that the server by default responds by completing the  
            HTTP request after a delay of 25 seconds. This delay is to ensure the client app can have enough time 
            to enter suspended state and then receive the incoming HTTP response from the server. 
            </TextBlock> 
            <Grid x:Name="ClientSettings" Margin="5"> 
                <Grid.RowDefinitions> 
                    <RowDefinition/> 
                    <RowDefinition/> 
                    <RowDefinition/> 
                </Grid.RowDefinitions> 
                <TextBlock  Grid.Row="0" Text="Server Name: " TextWrapping="Wrap" VerticalAlignment="Center" Style="{StaticResource BasicTextStyle}" /> 
                <TextBox Grid.Row="1" Grid.ColumnSpan="2" x:Name="ServerUri" Text="http://Server-HostName/CCTHttpServerSample/default.aspx" HorizontalAlignment="Left" VerticalAlignment="Center" /> 
                <StackPanel Orientation="Horizontal" Grid.Row="2"> 
                    <Button x:Name="ConnectButton" Content="Connect" Click="ConnectButton_Click" /> 
                    <Button x:Name="ClearButton" Content="Clear Log" Click="ClearButton_Click" /> 
                </StackPanel> 
            </Grid> 
        </StackPanel> 
        <!-- Add Storyboards to the visual states below as necessary for supporting the various layouts for the input section --> 
        <VisualStateManager.VisualStateGroups> 
            <VisualStateGroup> 
                <VisualState x:Name="InputDefaultLayout"/> 
                <VisualState x:Name="InputBelow768Layout"/> 
            </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
    </Grid> 

    <Grid x:Name="Output" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1"> 
        <ScrollViewer 
      HorizontalScrollBarVisibility="Disabled" 
      VerticalScrollBarVisibility="Auto" 
      HorizontalScrollMode="Disabled" 
      VerticalScrollMode="Enabled" 
      ZoomMode="Disabled" 
      Margin="10,4,10,0"> 
            <TextBlock x:Name="DebugTextBlock"  
                   TextWrapping="Wrap" 
                   Style="{StaticResource BasicTextStyle}" 
                   IsTextSelectionEnabled="True" /> 
        </ScrollViewer> 
        <!-- Add Storyboards to the visual states below as necessary for supporting the various layouts for the output section --> 
        <VisualStateManager.VisualStateGroups> 
            <VisualStateGroup> 
                <VisualState x:Name="OutputDefaultLayout"/> 
                <VisualState x:Name="OutputBelow768Layout"/> 
            </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
    </Grid> 
</Grid> 

I would expect the ScrolViewer at the bottom (and want it) to put a scroll bars around the TextBlock as and when its requires it.

The sample shows debug in the TextBlock, but when it fills, the entire Layout becomes scrollable rather then just the TextBlock.

Can you tell me why? And what I need to do to make the scroll bars appear around the TextBlock only?

Was it helpful?

Solution

Just needed a height. Height="200"

    <ScrollViewer 
  HorizontalScrollBarVisibility="Disabled" 
  VerticalScrollBarVisibility="Auto" 
  HorizontalScrollMode="Disabled" 
  VerticalScrollMode="Enabled" 
  ZoomMode="Disabled" 
  Margin="10,4,10,0"> 
        <TextBlock x:Name="DebugTextBlock"  
               TextWrapping="Wrap" 
               Style="{StaticResource BasicTextStyle}" 
               IsTextSelectionEnabled="True"  Height="200"/> 
    </ScrollViewer> 
    <!-- Add Storyboards to the visual states below as necessary for supporting the various layouts for the output section --> 
    <VisualStateManager.VisualStateGroups> 
        <VisualStateGroup> 
            <VisualState x:Name="OutputDefaultLayout"/> 
            <VisualState x:Name="OutputBelow768Layout"/> 
        </VisualStateGroup> 
    </VisualStateManager.VisualStateGroups> 
</Grid> 

The reason this didn't work originally, is due to the parent layout having a ScrollViewer, making this scroll view nested.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top