tags:

views:

10471

answers:

3

Hello,

I have a databound and itemtemplated ListBox:

<ListBox x:Name="lbLista" 
         ScrollViewer.VerticalScrollBarVisibility="Visible">
    <ListBox.ItemTemplate>
      <DataTemplate>
        <StackPanel Orientation="Horizontal">
          <CheckBox IsChecked="{Binding Deleteable, Mode=TwoWay}" />
          <Label Content="{Binding Name}" />
        </StackPanel>
      </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

The ites show fine and they come from an ObservableCollection.

The problem is the scrollbar which appears but is not usable - it does not have a handle to grab. I've tried setting some ScrollView attached properties on ListBox, but they do not affect the situation.

Any ideas folks?

-pom-

+4  A: 

I pasted your code into test project, added about 20 items and I get usable scroll bars, no problem, and they work as expected. When I only add a couple items (such that scrolling is unnecessary) I get no usable scrollbar. Could this be the case? that you are not adding enough items?

If you remove the ScrollViewer.VerticalScrollBarVisibility="Visible" then the scroll bars only appear when you have need of them.

Muad'Dib
+2  A: 

ListBox will try to expand in height that is available.. When you set the Height property of ListBox you get a scrollviewer that actually works...

If you wish your ListBox to accodate the height available, you might want to try to regulate the Height from your parent controls.. In a Grid for example, setting the Height to Auto in your RowDefinition might do the trick...

HTH

Arcturus
Thank you for answer HTH. You speak little, but every word is covered in gold. =)
Pompair
Hehe.. thanks.. my native language isn't the English one ;)
Arcturus
A: 

Hi,

Thnaks for answer. I tried it myself too to an Empty Project and - lo behold allmighty creator of heaven and seven seas - it worked. I originally had ListBox inside which was inside of root . For some reason ListBox doesn't like being inside of StackPanel, at all! =)

-pom-

Pompair
You should really accept the original answer that help you, not your own confirmation. :-)
Franci Penov
Credit where creit is due and all that...
Franci Penov