Jump to content



Photo

XAML Scrollviewer not scrolling: WP8

xaml windows phone 8

  • Please log in to reply
4 replies to this topic

#1 James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 27 August 2013 - 13:34

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>



#2 SledgeNZ

SledgeNZ

    Neowinian

  • Tech Issues Solved: 2
  • Joined: 18-June 12

Posted 27 August 2013 - 13:42

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.



#3 OP James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 27 August 2013 - 14:10

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.



#4 SledgeNZ

SledgeNZ

    Neowinian

  • Tech Issues Solved: 2
  • Joined: 18-June 12

Posted 27 August 2013 - 14:32

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.



#5 OP James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 27 August 2013 - 14:40

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