Eels Fan
Eels Fan

Reputation: 2063

TextBox Scrolling in Windows Phone App not working

I have a page in a Windows Phone app. This page is rather "tall". For that reason, the entire page is wrapped in a ScrollViewer. Towards the bottom of the page is a TextBox. This TextBox is intended to be a multi-line TextBox with TextWrapping="Wrap". I need for the user to be able to scroll up-and-down within the TextBox to see the content they have typed. However, I am unable to scroll within the TextBox itself. Instead, when I attempt to scroll, the entire page scrolls. How do I remedy this? I tried adding ScrollViewer.VerticalScrollBarVisibility="Auto" however, that does not seem to work either. Here is an exerpt of my XAML.

<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}">
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
  </Grid.RowDefinitions>

  <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
    <TextBlock x:Name="ApplicationTitle" Text="APPNAME" Style="{StaticResource PhoneTextNormalStyle}" />
    <TextBlock x:Name="PageTitle" Text="{Binding Path=PageTitle}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
  </StackPanel>

  <ScrollViewer Grid.Row="1">
    <Grid x:Name="ContentPanel" Margin="12,0,12,0">
       ...
      <TextBox x:Name="bodyTextBox" Text="{Binding Path=Body, Mode=TwoWay}" Height="145"  TextWrapping="Wrap" InputScope="Text" Grid.Row="6" MaxLength="1024" Margin="0,-8,0,0" />
    </Grid>
  </ScrollViewer>
</Grid>

Thank you for any insights you may provide.

Upvotes: 2

Views: 2547

Answers (2)

marcusdev
marcusdev

Reputation: 19

To have a scrolling multi-line textbox you don't need to use the scrollviewer, you just enable acceptsreturn , textwrapping="wrap", maxheight="160" (to see the multi-lines) plus VerticalScrollBarVisibility="Visible".

To see the scrolling in the textbox, you click and hold the button down then you get a caret appear, now move it up and down and it will scroll through the textbox.

Upvotes: 0

Brian Alvarez
Brian Alvarez

Reputation: 96

In my experience, this is usually caused by incorrectly using an "auto" height tag or a "starSizing" height tag somewhere. I would try setting fixed heights for relevant elements (especially your RowDefinition) and see that helps

Upvotes: 2

Related Questions