Question

I have the following XAML code:

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="#FFE8E8E8">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,0" >
        <TextBlock  x:Name="AppName" Text="Agent" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0" Foreground="Black" />
        <TextBlock  x:Name="PageName" Text="agent audit" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Height="100" Foreground="Black"/>
    </StackPanel>

    <Grid x:Name="ContentPanel" Grid.Row="1" Background="White"/>

    <ScrollViewer HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="1" VerticalAlignment="Top">
        <TextBlock x:Name="auditText"  HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="1" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Foreground="Black" Padding="10"/>
    </ScrollViewer>
</Grid>

When the page comes into view I assign the TextBlock with the contents of an API Call (audit log text), and this gets quite long.

However, currently it cuts off all text below the screen height. I have the TextBlock and ScrollView set to Auto layout height/width.

I can even see the top of the next line of text, when I scroll the rest doesn't appear. Quite hard to screenshot too as you only see the issue when scrolling, and whilst scrolling I can't take a screenshot :/

Any ideas where I'm going wrong?

I've read numerous posts on this site but nothing quite hit what I was after.

Thanks.

Was it helpful?

Solution

This ended up working for me:

<ScrollViewer Height="Auto"  Grid.Row="1">
            <TextBlock x:Name="auditText" Text="TextBlock" 
         VerticalAlignment="Top" Foreground="Black" Margin="0,10,0,0" Grid.Row="1" Padding="20" TextWrapping="Wrap">
            </TextBlock>
        </ScrollViewer>

Setting the ScrollViewer height to AUTO

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