2

Closed

WrapPanel inside of a ListBox

description

Hi,
 
I tried to use the WrapPanel that comes with the Silverlight Toolkit inside of a ListBox. Now the good news is that everything renders just as I would expect, great job!
 
However I was also expecting the standard ListBox keyboard behavior to stay intact and let me scroll through the ListBox using the keydown and keyup. Of course I was hoping this would also work to the left and right :-)
 
Anyway the down and up arrow do scroll the list then there are enough items in there but they no longer change the selected item. Is there a way to get the keyboard behavior back?
 
The XAML I was using looks like this:
<UserControl xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls" x:Class="SilverlightApplication3.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
    <ListBox x:Name="DemoList">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <controls:WrapPanel />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.Template>
            <ControlTemplate>
                <Grid>
                    <ScrollViewer>
                        <ItemsPresenter />
                    </ScrollViewer>
                </Grid>
            </ControlTemplate>
        </ListBox.Template>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding}"
                           TextAlignment="Right"
                           Width="25" />
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
 
</Grid>
</UserControl>
 
See the attached solution for the complete code.
 
TIA
Maurice

file attachments

Closed Aug 11, 2012 at 1:00 AM by RohanTha
Bulk closing issues older than 2 years. Please reactivate if you still have this problem.

comments

wrote Jan 13, 2009 at 10:45 PM

01/09/2009 17:31:53

ListBox's keyhandling code would need to change to enable this scenario.