加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows-phone-7 – ‘VisualTree’设置不止一次

发布时间:2020-12-13 20:18:29 所属栏目:Windows 来源:网络整理
导读:我在这个xaml文件中收到错误: The property ‘VisualTree’ is set more than once. ListBox x:Name="lstHistory" HorizontalAlignment="Left" Margin="12,284,90" Width="460" ItemsSource="{Binding Source={StaticResource SongCollection},Path=DataCol
我在这个xaml文件中收到错误:

The property ‘VisualTree’ is set more than once.

<ListBox x:Name="lstHistory" HorizontalAlignment="Left" Margin="12,284,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,8,8"
                  VerticalAlignment="Top"
                  HorizontalAlignment="Left"
                  Text="{Binding Path=Artist}" />
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

谁能帮忙?

DataTemplate只能有1个小孩.你有2(stackpanel和textblock).将其包装在单个容器中,一切都会很好

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读