Reputation: 178
<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
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