我在此 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/