2012-05-16 25 views
14

tôi tiếp tục nhận được một lỗi trong file XAML này:'VisualTree' được thiết lập nhiều hơn một lần

Thuộc tính 'VisualTree' được thiết lập nhiều hơn một lần.

<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> 

Bất cứ ai có thể giúp đỡ?

Trả lời

23

DataTemplate chỉ có thể có 1 con. bạn đã có 2 (stackpanel và textblock). bọc chúng vào thùng chứa đơn và tất cả sẽ tốt

Các vấn đề liên quan