andruX
andruX

Reputation: 117

how to add scroll-bar to windows store app?

I am making an app for windows store; Like in c# we used Scroll bars to move down to the end of page and view all content, How can we do it for windows store? Like how to arrange data and use scroll bars to move to right and view all the data?

Upvotes: 0

Views: 1156

Answers (1)

Filip Skakun
Filip Skakun

Reputation: 31724

Typically you don't use ScrollBar controls directly and rather put your content in a Panel (usually Grid/StackPanel/Canvas) and put that panel inside of a ScrollViewer. Make sure to set Horizontal/Vertical-Scroll-Mode/BarVisibility and ZoomMode properties to match the direction of scrolling you want supported.

The benefit of using the ScrollViewer instead of ScrollBar is that you get smooth panning with touch that the platform handles for you with the Direct Manipulation layer that is not exposed to you in WinRT/XAML and also handles all the other inputs in a standard way.

Also if you are dealing with a list of items you want to scroll through, especially when the list is long - you would use some ItemsControl subclass - typically a vertical ListView for long, mostly text content lists or horizontal GridView for lists of richer media items. The benefit of using those is that they handle list virtualization for you - i.e. for lists of thousands of items you only get few item containers generated for the items currently visible in the control's view port and ones that are near the view port so they are ready when you scroll to them.

The templates of these list controls internally already have a ScrollViewer and the ScrollViewer's template has ScrollBars inside.

Upvotes: 1

Related Questions