Same as this question, but for UWP. In particular, I can't find any SystemParameters class, so the answer there does not work in my case.
Also important: If at all possible, I would like to be able to get the width a scrollbar would have if it existed. In other words, there are cases where the scrollbar does not exist yet, but user input is likely to cause it to be created. In such a case, I want to be able to know what width it is expected to have if/when it is created. (I realize something unexpected might cause the answer to be wrong; that's ok, as long as I'm getting the usual expected answer.)
As @Neme's answer said, you can use VisualTreeHelper to retrieve the ScrollBar and then use ActualWidth property to get its width.
However, if you didn't change
VerticalScrollBar
's styles and templates, the width ofVerticalScrollBar
would always be 12. You can find this in ScrollBar styles and templates.For
VerticalScrollBar
, its width won't change so itsActualWidth
would always be 12. And forHorizontalScrollBar
, its height won't change so itsActualHeight
would always be 12. These value changes only when we change scrollbar's style or template. And in this scenario, we should know the width we've set, or we can retrieve it at runtime by using VisualTreeHelper.