Die Elementsammlung muss leer sein, bevor ItemsSource verwendet werden kann

Wenn ich einen DataTrigger in eine einfache Listbox lege, erhalte ich diese Laufzeitausnahme:

Die Elementsammlung muss leer sein, bevor ItemsSource verwendet werden kann

Meine Listbox ohne Datentrigger (keine Ausnahme):

<ListBox ItemsSource="{Binding EdgedBoards}" SelectedItem="{Binding SelEdgedBoard, Mode=TwoWay}" DisplayMemberPath="Name">
    <ListBox.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}" 
               BasedOn="{StaticResource {x:Type ListBoxItem}}">

            <Setter Property="IsSelected"
                    Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>

Meine ListBox mitDataTrigger:

<ListBox ItemsSource="{Binding EdgedBoards}" SelectedItem="{Binding SelEdgedBoard, Mode=TwoWay}" DisplayMemberPath="Name">
    <Style TargetType="{x:Type ListBox}" BasedOn="{StaticResource {x:Type ListBox}}">
        <Setter Property="Focusable" Value="True" />

        <Style.Triggers>
            <DataTrigger Binding="{Binding ElementName=EdgedBoardsAdd_UC, Path=Visibility}" Value="Visible">
                <Setter Property="Focusable" Value="False" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <ListBox.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>

Was ist los mit dem letzteren Code?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage