I\'d like to change the properties of a ScrollViewer
of a ListBox
from C#.
I found this question here on Stackoverflow. I took the accepted
As for me, exposing ScrollViewer as a property is a bad idea. Firstly, there is no guarantee that ScrollViewer exists in a template. Secondly, ScrollViewer works in sync with ItemsPanel and ItemContainerGenerator. Overriding this is the straight way to uncommon behavior.
WPF controls use another pattern. Their classes are like mediators between outer logical usage and inner visual representation. Your ListBox should expose properties which can be used by ScrollViewer in a template, but not ScrollViewer. By doing this, you break WPF standards, restrict your control to specific template, and allows user code to hack internal ListBox implementation.