How can I disable horizontal scrolling in a WPF Li

2019-01-31 10:55发布

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条回答
Anthone
2楼-- · 2019-01-31 10:57

In XAML:

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" />

In C#:

myListBox.SetValue(
    ScrollViewer.HorizontalScrollBarVisibilityProperty,
    ScrollBarVisibility.Disabled);
查看更多
登录 后发表回答