locked
How to make the vertical scroll bar of scrollviewer to be always visible?

    Question

  • Hello, dear all,

     

    I found I couldn't make the vertical scroll bar of a textbox/textblock always be visible. Take the following two scenarios as the examples:

    1. Setting the ScrollViewer.VerticalScrollBarVisibility of the textbox/textblock to visible, like:

        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
          <TextBox x:Name="MyTextBox" FontSize="28" ScrollViewer.VerticalScrollBarVisibility="Visible" HorizontalAlignment="Left" Height="100" Margin="306,101,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="389"/>
       </Grid>
    
     

    2. Using a stackpannel, like:

       <ScrollViewer x:Name="MyScrollViewer" Height="300" MaxHeight="300" Margin="0,0,0,20" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalScrollBarVisibility="Visible">
          <TextBlock x:Name="MyTextBlock" Margin="5,5,5,5" FontSize="16" TextWrapping="Wrap" />
       </ScrollViewer>
    

    If the content is really too much, the vertical scroll bar could be shown if I move the mouse into the TextBox/TextBlock, otherwise it will not be shown.

     

    So how could I always show the vertical scroll bar regardless whether there is much or less content in the TextBox/TextBlock?

     

    Thanks!

    Thursday, March 06, 2014 1:43 AM

Answers

  • Why do you want this?

    How do you plan to deal with the difference between the mouse and the touch scrollbars?

    You can modify the template, but consider if this is a good UI or not.

    --Rob

    • Marked as answer by B0L Monday, March 17, 2014 5:20 AM
    Thursday, March 06, 2014 2:35 AM
    Owner

All replies

  • Why do you want this?

    How do you plan to deal with the difference between the mouse and the touch scrollbars?

    You can modify the template, but consider if this is a good UI or not.

    --Rob

    • Marked as answer by B0L Monday, March 17, 2014 5:20 AM
    Thursday, March 06, 2014 2:35 AM
    Owner
  • Hi, Rob, thanks for your quick reply. Yeah, the look-and-feels for the mouse and the touch scrollbars are different. Is this the reason that we couldn't make the scroll bar be always visible?

    Another question is: how to modify the template? Should I define another style based on the standard template of "ScrollViewer"? If yes, would you please give me any hint?

     

    Thanks!

     
    • Edited by B0L Thursday, March 06, 2014 7:48 AM
    Thursday, March 06, 2014 3:03 AM