ListBoxItem にコマンドを配置したい。ListBoxItem は、StackPanel (Image と TextBlock を含み、どちらも Binding を使用) で構成される DataTemplate を使用します。その ListBoxItem をダブルクリックすると、コマンドが起動されるようにしたいと思います。
私はこれを試しました:
<DataTemplate>
<StackPanel>
<StackPanel.Resources>
<CommonUI:CommandReference x:Key="DoubleClickCommand" Command="{Binding Path=DefaultCommand}" />
</StackPanel.Resources>
<StackPanel.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{StaticResource DoubleClickCommand}" />
</StackPanel.InputBindings>
<Image Source="{Binding Path=Thumbnail, IsAsync=True}" IsHitTestVisible="False"/>
<TextBlock Text="{Binding Path=Name}" IsHitTestVisible="False">
</StackPanel>
</DataTemplate>
また、この StackPanel を含む StackPanel に Command Resources を変更せずに配置しようとしました。InputBindings 部分を TextBlock に配置すると、それが機能するため、バインディングは確実です。
ありがとう