Sign in to follow this  
Followers 0

XAML Scrollviewer not scrolling: WP8


5 posts in this topic

Posted

Why in the heck is the ScrollViewer not doing anything?  I've been checking a number of options but no matter what, the text (filled via C#) does not scroll

 <Grid x:Name="LayoutRoot" Background="DarkRed">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="0,0,0,4" Grid.ColumnSpan="2">
            <Grid x:Name="TitlebarGrid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="55"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="55"/>
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" Height="48" Width="48" Source="/Assets/TinyTrain.png" Margin="4,5,4,4" />
                <Image Grid.Column="2" Height="48" Width="48" Source="/Assets/TinyTrain.png" Margin="50,5,-50,4" >
                    <Image.RenderTransform>
                        <ScaleTransform ScaleX="-1"/>
                    </Image.RenderTransform>
                </Image>
                <TextBlock HorizontalAlignment="Center" Grid.Column="1" Text="Big Apple Transit" FontSize="38" FontWeight="Bold" Style="{StaticResource PhoneTextNormalStyle}" Margin="0,0,0,0"/>
            </Grid>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0" Background="White" >
            <ScrollViewer Grid.Column="1" Height="auto" VerticalScrollBarVisibility="Visible" AllowDrop="False">
                <TextBlock Name="LineDetails" Opacity="0.0" Foreground="DarkRed" FontSize="24" TextWrapping="Wrap" />
            </ScrollViewer>
            
            <ListBox Name="BATList" Opacity="1.0" Foreground="DarkRed" FontSize="33" Margin="5" SelectionChanged="BATList_SelectionChanged">
                <ListBox.Resources>
                    <SolidColorBrush x:Key="AppAccentBrush" Color="#c0c0c0"></SolidColorBrush>
                </ListBox.Resources>
            </ListBox>
        </Grid>
    </Grid>

Share this post


Link to post
Share on other sites

Posted

A quick look at your xaml shows a few things:

The listbox is overlaying the scrollviewer

The scrollviewer has grid.column="1" set on it however the grid it's hosted in doesn't define any row or column definitions.

A textbox with wrap doesn't really need a scrollviewer as it has one within it's controltemplate to do... scrolling.

Share this post


Link to post
Share on other sites

Posted

A quick look at your xaml shows a few things:

The listbox is overlaying the scrollviewer

The scrollviewer has grid.column="1" set on it however the grid it's hosted in doesn't define any row or column definitions.

A textbox with wrap doesn't really need a scrollviewer as it has one within it's controltemplate to do... scrolling.

 

The ListBox is over the ScrollViewer because when the user selects a row in the ListBox the ListBox's Opacity is set to 0.0 so that the TextBlock is visible in the same space.   I have tried the ScrollViewer without the Grid.Column value as well (and wow, duh about the lack of Grid definitions) 

I have also tried the TextBlock with and without the WRAP but still not working

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0" Background="White" >
                <TextBlock Name="LineDetails" Opacity="0.0" Foreground="DarkRed" FontSize="24" TextWrapping="Wrap" />           
            <ListBox Name="BATList" Opacity="1.0" Foreground="DarkRed" FontSize="33" Margin="5" SelectionChanged="BATList_SelectionChanged">
                <ListBox.Resources>
                    <SolidColorBrush x:Key="AppAccentBrush" Color="#c0c0c0"></SolidColorBrush>
                </ListBox.Resources>
            </ListBox>
        </Grid>
    </Grid>

Thanks for the feedback though.

Share this post


Link to post
Share on other sites

Posted

If you remove the listbox from the 2nd grid does the text wrap? Could be it's contents are forcing the width of it's host grid to be extended beyond the bounds of your page.

Share this post


Link to post
Share on other sites

Posted

If you remove the listbox from the 2nd grid does the text wrap? Could be it's contents are forcing the width of it's host grid to be extended beyond the bounds of your page.

 

This didn't work:

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0" Background="White" >
            
                <TextBlock Name="LineDetails" Opacity="1.0" Foreground="DarkRed" FontSize="24" TextWrapping="Wrap" />           
            
        </Grid>

This did work:

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0" Background="White" >
            <ScrollViewer Grid.Column="1" Height="auto" VerticalScrollBarVisibility="Visible" AllowDrop="False">
                <TextBlock Name="LineDetails" Opacity="1.0" Foreground="DarkRed" FontSize="24" TextWrapping="Wrap" />
            </ScrollViewer>
        </Grid>

So I'll have to look into how to show the controls.   Thank you very much

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.