kkh
kkh

Reputation: 4869

Vertical scroll in a ListBox

Hi I have a list box as below inside a grid. I cant make the items inside the ListBox scrollable when the number of items exceed the height of the ListBox.

I added VerticalScrollBarVisibility="Visible" to the ListBox tag but it doesn't work at all.

Read somewhere about scrolling doesnt work in a stack panel.

Anyone can help me with this? Thanks in advance!

<ListBox>
    <TreeView>
       <TreeView.Resources>
           <HierarchicalDataTemplate>
               <StackPanel>
                 <TextBlock />
                 <TextBox></TextBox>
               </StackPanel>
           </HierarchicalDataTemplate>
       </TreeView.Resources>
    </TreeView>
</ListBox>

Upvotes: 1

Views: 1442

Answers (1)

Ankesh
Ankesh

Reputation: 4895

You should be using the ScrollView property:

<ListBox ScrollViewer.VerticalScrollBarVisibility="Auto"
         ScrollViewer.CanContentScroll="True">     
    <TreeView>
        <TreeView.Resources>            
            <HierarchicalDataTemplate>                
                <StackPanel>                  
                    <TextBlock/>                    
                    <TextBox></TextBox>                
                </StackPanel>            
            </HierarchicalDataTemplate>        
        </TreeView.Resources>     
    </TreeView> 
</ListBox>

It Should work...

Upvotes: 2

Related Questions