Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - ScrollView Confusion

I am new to WPF and the ScrollViewer is frustrating me. Either I just don't "get" it, or it is a limited control.

Here are my Frustrations:

  1. Bad Horizontal Scrolling The horizontal scroll bar is only visible at the bottom of the list (I have to scroll to the bottom to see it)

  2. Bad Borders I have a ListBox in my ScrollViewer. When I start the bottom of the list has no border and when I scroll down, the top border (line) of the list box disappears. I can kind of understand this, but attempts to set BorderThickness or BorderBrush for the ScrollViewer result in no change (I wanted to use the ScrollViewer's border to keep a constatant box around the list contents, like most list boxes out in cyber world).

  3. Bad Handling of Short Lists When the items in the list don't reach the bottom the ScrollViewer keeps the scroll bar there and just dithers it out. Why not free up some space and remove it?

Some of these may seem petty (and they are). But users expect a certain look and feel from their apps and WPF is making it hard to get this out of the box.

If you know a way to fix any of these I would love a response. If there is a better way to deal with scrolling than using the ScrollViewer that would aslo be welcome.

like image 416
Vaccano Avatar asked Dec 22 '22 07:12

Vaccano


1 Answers

  1. Maybe you see some scroll bar from inside the list rather than the scroll bar from the ScrollViewer? Try setting <ScrollViewer ... HorizontalScrollBarVisibility="Auto"> (default is Hidden, which means that no horizontal scroll bar is shown ever; also try "Visible" for the sake of debugging)

  2. Is putting a <Border> around the ScrollViewer an option?

  3. VerticalScrollBarVisibility has a default value of Visible. If you want the scroll bar to disappear when it is not necessary, try <ScrollViewer ... VerticalScrollBarVisibility="Auto">.

like image 136
Heinzi Avatar answered Jan 05 '23 18:01

Heinzi