SandyNegi.037
SandyNegi.037

Reputation: 178

How to dynamically create horizontally scrolling listbox of images in Windows phone 7.5

<ListBox x:Name="lstbox" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Visible">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>

I am able to create horizontally scrolling list of images via this design time code.
Right now i am able to add images at runtime,
But i am not able to produce same effect via code in runtime....

Upvotes: 1

Views: 1999

Answers (1)

janiss
janiss

Reputation: 158

One way to go:

        string xaml =
        "<ListBox x:Name='lstbox' ScrollViewer.VerticalScrollBarVisibility='Disabled' ScrollViewer.HorizontalScrollBarVisibility='Visible'>"+
        "<ListBox.ItemsPanel>"+
            "<ItemsPanelTemplate>"+
                "<StackPanel Orientation='Horizontal' />"+
            "</ItemsPanelTemplate>"+
        "</ListBox.ItemsPanel>";

UIElement tree = (UIElement)XamlReader.Load(xaml);

LayoutRoot.Children.Add(tree);

Upvotes: 3

Related Questions