ユーザーがアプリケーション内をナビゲートできるメニューを表示するListBoxがあります。 ListBox要素を選択すると、メニューの右側に対応するUserControlが表示されます。ただし、メニュー項目の1つ(ABOUT)はフォーカス可能ではなく、タスクを実行するだけです(ポップアップウィンドウを開く)。選択された項目は以前の状態に残るはずです。FocusableがFalseに設定されたListBox項目のマウスクリックの検出
次の提案this link関連するListBox要素のFocusableプロパティをVMのブール値プロパティにバインドしようとしました。しかし、私はSelectedIndexプロパティの更新を取得しません。
これを回避する手段はありますか?
XAML:
<ListBox Grid.Row="0"
ItemsSource="{Binding MenuButtonInfoList}"
SelectedIndex="{Binding SelectedMainMenuIndex, Mode=TwoWay}"
Background="Transparent" BorderBrush="Transparent" Padding="0"
VerticalContentAlignment="Center">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Focusable" Value="{Binding Path=Focusable}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Border Style="{StaticResource MenuButtonBorder}">
<StackPanel Orientation="Horizontal" Height="Auto">
<Image Source="{Binding ImageFilePath}"
Style="{StaticResource MenuButtonImage}" />
<Label Content="{Binding Label}"
Style="{StaticResource MenuButtonLabel}" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
あなたは '[IsHitTestVisibleを使用することができます'MSDNから](https://msdn.microsoft.com/en-us/library/system.windows.uielement.ishittestvisible(v = vs.110).aspx) – XAMlMAX
なぜあなたはうまくいきますかアイテムを選択できないようにするには、SelectedIndexプロパティが更新されることを期待していますか? – mm8
ListBox項目を選択できるようにしたいが、項目にフォーカスがあるようにする必要がある。他の項目では、MainWindowレイアウトの変更が発生しますが、ABOUT項目はポップアップウィンドウを開きます。したがって、ABOUT項目に焦点が当てられていても意味がありません。 – Oystein