解決策の 1 つは、ユーザーが変更できるようになるまで ListBox と ListBoxItems をフォーカスできないようにすることです。これを実現した簡単なモックアップを次に示します。
XAML:
<StackPanel>
<ListBox x:Name="LB">
<ListBoxItem Focusable="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=Focusable}" Content="item 1"/>
<ListBoxItem Focusable="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=Focusable}" Content="item 2"/>
<ListBoxItem Focusable="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=Focusable}" Content="item 3"/>
<ListBoxItem Focusable="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=Focusable}" Content="item 4"/>
<ListBoxItem Focusable="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=Focusable}" Content="item 5"/>
<ListBoxItem Focusable="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=Focusable}" Content="item 6"/>
</ListBox>
<Button Content="Lock/Unlock" Click ="Button_Click"/>
</StackPanel>
コード:
private void Button_Click(object sender, RoutedEventArgs e)
{
if (LB.Focusable == true)
LB.Focusable = false;
else
LB.Focusable = true;
}