Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'VisualTree' is set more than once

I keep getting an error in this xaml file:

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>

Anyone who can help?

like image 794
Jerodev Avatar asked May 16 '12 15:05

Jerodev


1 Answers

DataTemplate can only have 1 child. you've got 2 (stackpanel and textblock). wrap those in single container and all will be well

like image 130
Robert Levy Avatar answered Oct 14 '22 01:10

Robert Levy