C Sharp Scroll Bar

From Leo's Notes
Revision as of 05:38, 24 December 2012 by Leo (talk | contribs) (Created page with "The scroll bar in WPF has a property named <code>ViewportSize</code> which controls the size of the thumb. The <code>ViewportSize</code> is calculated using the formula below:...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 24 December 2012, at 05:38.

The scroll bar in WPF has a property named ViewportSize which controls the size of the thumb. The ViewportSize is calculated using the formula below:

ViewportSize = range * percent / (1 - percent)

where

* range is the range of the scroll bar.
* percent is the percentage of content covered by the scroll bar between 0.0 and 0.99

You will need to ensure that the view port size is not infinity (from a division by zero).