3

I need to get a notification when ComputedHorizontalScrollBarVisibility changes. Sadly, there is no Event for that. Is there a way to do this? Maybe with inheritance?

Display Name
  • 448
  • 2
  • 5
  • 14

1 Answers1

6

http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrollchanged(v=vs.85).aspx

On ScrollChanged, check ComputedHorizontalScrollBarVisibility.

sq33G
  • 3,320
  • 1
  • 23
  • 38
  • Thanks. I tried to get it working with the SizeChanged event, but this works much better. [Here](http://stackoverflow.com/questions/14963104/wpf-scrollviewer-desiredsize-does-not-increase-when-scrollbar-gets-visible/15186802)'s my use case. – Mike Fuchs Mar 11 '13 at 14:01
  • In my testing, I've found that ComputedHorizontalScrollBarVisibility is not always correct. I don't know why, but I think it has something to do with how the layout is updated, and the order of operations of said update. Just FYI if you go down this road. ComputedHorizontalScrollBarVisibility may very well be set to collapsed even though it's actually visible. – Krythic Jul 23 '21 at 19:13
  • After further testing, the above bug does not occur with the ScrollChanged event, so I recommend depending solely upon that. – Krythic Jul 23 '21 at 19:18