How to scroll a TextBox horizontally just like the WP7 Browser's address

Go To StackoverFlow.com

1

I have a TextBox in my Wp7 app which can contain more data than can fit on the viewable screen. I'd like to give the user the ability to actually read the text by scrolling it. This is the way the browser's address bar works. Just slide the text from side to side to read it. Tapping on the text, you enter edit mode (and even in edit-mode, the user can slide the text). I need this to be a TextBox and not a TextBlock because I need data-entry on this field too.

Anybody have any ideas on how this was accomplished in the browser?

Thanks...

2012-04-03 23:09
by Mark Wager-Smith


1

You could scroll the entire textbox control, rather than the text within the textbox using the following :-

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <ScrollViewer Grid.Row="0"
                      VerticalScrollBarVisibility="Disabled"
                      HorizontalScrollBarVisibility="Visible">
            <TextBox Text="Some really long sample text which we are going to scroll" />
        </ScrollViewer>
    </Grid>

Hope this helps.

2012-04-04 08:01
by Paul Diston