How can I disable horizontal scrolling in a WPF ListBox?


Question

This seems to be an absurdly simple question but Google and Stack Overflow searches yield nothing. How can I disable horizontal scrolling in a WPF ListBox when items take up more horizontal space than is available in the box?

1
116
9/18/2018 12:09:29 PM

Accepted Answer

In XAML:

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" />

In C#:

myListBox.SetValue(
    ScrollViewer.HorizontalScrollBarVisibilityProperty,
    ScrollBarVisibility.Disabled);
254
9/18/2018 11:47:25 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon