Mahadesh
Mahadesh

Reputation: 53

Hiding the scrollbar for a listbox in Silverlight

Please let me know how i can hide the scrollbar from being displayed in Silverlight. I dont want vertical or horizontal scrollbar. i want to hide both . PLease help

Upvotes: 2

Views: 2367

Answers (1)

Chris Anderson
Chris Anderson

Reputation: 8369

You can set the ScrollViewer.HorizontalScrollBarVisibility and/or ScrollViewer.VerticalScrollBarVisibility attached properties to "Disabled". For example, if you have the following XAML:

<ListBox Height="100" Name="listBox1" Width="100">
    <ListBoxItem>
        <Rectangle Width="200" Height="50" Fill="#FF894220" />
    </ListBoxItem>
    <ListBoxItem>
        <Rectangle Width="200" Height="50" Fill="#FFB94222" />
    </ListBoxItem>
</ListBox>

You will therefore get scrollbars, like so:

[Unfortunately StackOverflow won't let me post the images until I get a higher reputation (which I'm trying to build). You'll have to imagine it or try it yourself]

Adding the ScrollViewer attached properties to the ListBox element:

<ListBox Height="100" Name="listBox1" Width="100"
         ScrollViewer.HorizontalScrollBarVisibility="Disabled"
         ScrollViewer.VerticalScrollBarVisibility="Disabled">
    <ListBoxItem>
        <Rectangle Width="200" Height="50" Fill="#FF894220" />
    </ListBoxItem>
    <ListBoxItem>
        <Rectangle Width="200" Height="50" Fill="#FFB94222" />
    </ListBoxItem>
</ListBox>

results in no scrollbars.

Hope this helps...

Chris

Upvotes: 8

Related Questions