How can I disable horizontal scrolling in a WPF ListBox?

15

Solution 1

In XAML:

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" />

In C#:

myListBox.SetValue(
    ScrollViewer.HorizontalScrollBarVisibilityProperty,
    ScrollBarVisibility.Disabled);

Solution 2

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>
Share:
15
sadelbrid
Author by

sadelbrid

Updated on November 28, 2020

Comments

  • sadelbrid
    sadelbrid over 3 years

    I've been having a lot of issues updating AS on my mac. Here's my current issue. I uninstalled my old version following the instructions here and downloaded the latest version from the android website. After mounting the dmg and placing AS in my applications folder, I try to launch it. However it stalls at the launch graphic. The loading bar moves all the way to the right and nothing else happens. Thoughts? Also, my JDK/JRE are up to date.

  • Eftekhari
    Eftekhari over 6 years
    If it doesn't work for you then use this simple answer >> stackoverflow.com/a/1739298/2123400