Windows phone 7 如何在WindowsPhone7.5中动态创建图像的水平滚动列表框

Windows phone 7 如何在WindowsPhone7.5中动态创建图像的水平滚动列表框,windows-phone-7,listbox,horizontal-scrolling,Windows Phone 7,Listbox,Horizontal Scrolling,我可以通过此设计时代码创建图像的水平滚动列表。 现在我可以在运行时添加图像, 但我无法在运行时通过代码产生相同的效果….一种方法: <ListBox x:Name="lstbox" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Visible"> <ListBox.ItemsPanel>

我可以通过此设计时代码创建图像的水平滚动列表。
现在我可以在运行时添加图像,
但我无法在运行时通过代码产生相同的效果….

一种方法:

<ListBox x:Name="lstbox" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Visible">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
stringxaml=
""+
""+
""+
""+
""+
"";
UIElement树=(UIElement)XamlReader.Load(xaml);
LayoutRoot.Children.Add(树);

为什么您需要使用代码而不是直接在XAML中执行此操作?请添加更多内容。@Cybermaxs“标题中没有标记”指的是类似“[Windows Phone 7]如何动态…”这样的标题没有问题,“如何…在Windows Phone 7中”,这是一个格式良好的英语句子。非常感谢您的解决方案,这对我来说很有效……但我不能投票,因为它需要15个声誉,而现在我没有。。
        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);