Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested ListBox scrolling issue

I have a listbox within listbox and when I try to reduce the height of the window the scrollbar for the listbox does not appears up. I want to dispaly the scrollbar on the outer listbox because the outerlistbox can have multiple innner listboxes. here is the XAML I am using. Can anybody let me know what is the issue?

<ListBox Name="MasterListBox" HorizontalAlignment="Stretch" Width="200">
    <ListBoxItem >
        <ListBox Name="Child1" BorderBrush="{x:Null}">
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
        </ListBox>
    </ListBoxItem>

</ListBox>
like image 724
amrit Avatar asked May 09 '26 14:05

amrit


1 Answers

If I am getting you right, you dont want the inner listboxes to scroll.

There are two ways to achieve that:

1) Change inner listbox to ItemsPanel. 2) If you really need to preserve the inner control as ListBox you have to replace the ScrollViewer with a ContentPresenter in the Template of the inner Listbox control. See this link (it`s marked as correct answer) > http://forums.silverlight.net/t/193872.aspx/1

like image 199
Josef Jura Avatar answered May 11 '26 02:05

Josef Jura