C Sharp Scroll Bar: Difference between revisions

From Leo's Notes
This page was last edited on 24 February 2017, at 19:14.
m Text replacement - "<code>" to "{{code|"
m Text replacement - "</code>" to "}}"
 
Line 1: Line 1:
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:
The scroll bar in WPF has a property named {{code|ViewportSize}} which controls the size of the thumb. The {{code|ViewportSize}} is calculated using the formula below:


  ViewportSize = range * percent / (1 - percent)
  ViewportSize = range * percent / (1 - percent)


where
where
  * {{code|range</code> is the range of the scroll bar.
  * {{code|range}} is the range of the scroll bar.
  * {{code|percent</code> is the percentage of content covered by the scroll bar between 0.0 and 0.99
  * {{code|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).
You will need to ensure that the view port size is not infinity (from a division by zero).

Latest revision as of 19:14, 24 February 2017

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).