UWP XAML/C# ScrollBar.

VoyTec 671 Reputation points

How to make ScrollBar working? It's empty for me and not showing. How to make lower screen?

<ScrollBar x:Name="scrollBar" HorizontalAlignment="Left" Margin="1254,10,0,0" VerticalAlignment="Top" Height="806" Width="25" Foreground="#FF221760" Background="#FF931C1C" Maximum="90" SmallChange="1" Value="10" ViewportSize="10" LargeChange="10"/>  
Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,731 Reputation points Microsoft Vendor


    Welcome to Microsoft Q&A!

    Just in addition to @Castorix31 's answer, I just want to add something about how to use the ScrollBar.

    First, the IndicatorMode property is the key to show the scrollbar because the value influences transition animations that are part of the ScrollBar. The ScrollBar is a control which could receive scrolling events. It does not mean creating a ScrollBar will implement the scroll function automatically. You will need to handle the ScrollBar.Scroll Event by yourself. Then you could move the position of the target element like scrolling based on the scroll value of the scroll event. This will be complicated. I will suggest use ScrollViewer when it is required to have scroll function.

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Castorix31 83,106 Reputation points

    You must add too :

    IndicatorMode ="MouseIndicator"  

    (also are you sure the Left Margin is not too big (1254) ?

    1 person found this answer helpful.
    0 comments No comments