How add a ItemsPanel dynamically to listbox.

Posted by Subhen on Stack Overflow See other posts from Stack Overflow or by Subhen
Published on 2010-05-25T06:33:25Z Indexed on 2010/05/25 11:31 UTC
Read the original article Hit count: 487

Hi, I have a list Box which contains few Images in the itemsTemplate , like below:

<ListBox.ItemTemplate> 
                <DataTemplate>
                    <StackPanel x:Name="stackPanelItems" Orientation="Horizontal">
                            <Image Source="{Binding strAlbumcoverImage}" 
                                   Height="40" Width="40"/>
                   </StackPanel>
             </DataTemplate>
</ListBox.ItemTemplate>

Now onClick of a button I want to change the view and for that I want to add the wrap panel to the ListBox ItemsPanelas following:

 <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <controlsToolkit:WrapPanel></controlsToolkit:WrapPanel>
                </ItemsPanelTemplate>
 </ListBox.ItemsPanel>

Do I need to define the ItemsPanel Style in App.XAML and then assign it. Not quite sure about it.

Thanks,

Subhen

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about silverlight-3.0