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?
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?
In XAML:
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
In C#:
myListBox.SetValue(
ScrollViewer.HorizontalScrollBarVisibilityProperty,
ScrollBarVisibility.Disabled);
If you created the Listbox from codebehind and want to make the change in XAML:
<UserControl.Resources>
<Style TargetType="{x:Type ListBox}" x:Key="{x:Type ListBox}" >
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
</Style>
</UserControl.Resources>