我在这个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).将其包装在单个容器中,一切都会很好
原文链接:https://www.f2er.com/windows/371359.html