windows-phone-7 - 'VisualTree' 设置不止一次

标签 windows-phone-7 xaml

我在此 xaml 文件中不断收到错误消息:

The property 'VisualTree' is set more than once.


<ListBox x:Name="lstHistory" HorizontalAlignment="Left" Margin="12,284,0,90" Width="460"
                 ItemsSource="{Binding
                                Source={StaticResource SongCollection},
                                Path=DataCollection}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Margin="5" VerticalAlignment="top" Source="{Binding Path=Image}" />
                    </StackPanel>
                    <TextBlock Margin="8" Width="250"
                  TextWrapping="Wrap"
                  VerticalAlignment="Top"
                  HorizontalAlignment="Left"
                  Text="{Binding Path=Name}" />
                    <TextBlock Width="100"
                  Margin="8,0,8,8"
                  VerticalAlignment="Top"
                  HorizontalAlignment="Left"
                  Text="{Binding Path=Artist}" />
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

任何人都可以提供帮助?

最佳答案

DataTemplate 只能有 1 个 child 。你有 2 个(堆栈面板和文本块)。把它们包在一个容器里,一切都会好起来的

关于windows-phone-7 - 'VisualTree' 设置不止一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10621454/

相关文章:

windows-phone-7 - 如何指定用于给定客户端上的所有 Restsharp 请求的 DateFormat?

c# - 有没有办法判断用户是否点击了屏幕上的任意位置?

c# - 从不同的线程启动/停止 DispatcherTimer

wpf - 如何将 WPF Tab Control 选项卡放在侧面

c# - CRM 2011 Silverlight 应用程序 - 无法将项目添加到 DataGridTemplateColumn 单元格内的组合框

c# - javascript 元素的大小无法正常工作

c# - 运行动画后如何导航到另一个页面

wpf - 有没有更好/更简洁的方式来声明这个重复的 WPF 绑定(bind)?

xaml - 如何在 Xamarin 中调整按钮的大小

WPF 绑定(bind) : Object in a object