0

Why does this code throw the "VisualTree set more than once" error on the textblock with the run for Employee number, name, and truck number? It is in within the data template. I tried wrapping that portion in a grid and it didn't work.

  <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width=".5*"/>
        <ColumnDefinition Width=".5*"/>
    </Grid.ColumnDefinitions>

    <ListView Grid.ColumnSpan="2" Grid.Row="0" BorderBrush="Transparent" Background="Transparent" Name="lvDriverQueueWork" ItemsSource="{Binding ICollectionQueueList, UpdateSourceTrigger=PropertyChanged}" Margin="10,0,10,0" Foreground="Black" AllowDrop="True">
        <ListView.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <TextBlock FontSize="14" FontWeight="SemiBold" Background="Transparent">
                            <Run Text="{Binding Path=Items[0].EmployeeNumber}"/>
                            <Run Text="-"/>
                            <Run Text="{Binding Name, Mode=OneWay}"/>
                            <Run Text="-"/>
                            <Run Text="{Binding Path=Items[0].TruckNumber}"/>
                        </TextBlock>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </ListView.GroupStyle>
        <ListView.ItemContainerStyle>
            <Style TargetType="{x:Type ListViewItem}">
                <Style.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#F7F6E4"/>
                    <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="black"/>
                </Style.Resources>
                <Setter Property="Margin" Value="0,0,0,-1"/>
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="BorderBrush" Value="Transparent" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.ItemTemplate>
            <ItemContainerTemplate>
                <Border BorderThickness="0,1,0,1" Padding="0,2,0,2" BorderBrush="#DCE1E5" Width="250">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Padding="18,0,0,0" Text="{Binding Trailer, UpdateSourceTrigger=PropertyChanged}"/>
                    <TextBlock Grid.Column="1" Text="{Binding Carrier, UpdateSourceTrigger=PropertyChanged}"/>
                </Grid>
                </Border>
            </ItemContainerTemplate>
        </ListView.ItemTemplate>
    </ListView>
</Grid>
JTester
  • 463
  • 1
  • 8
  • 19
  • there is no way this could throw such an error. You should build and run your project anyway. Don't believe in what XAML editor reports to you. In fact there are some bugs in the XAML editor. Some projects of mine have many reported errors by the XAML editor but they build and run totally fine. – King King Sep 06 '14 at 09:46
  • Yeah I noticed that it compiles and runs just fine with no error in the output window. – JTester Sep 06 '14 at 21:00

0 Answers0