<local:MonthItem.InputBindings>
<MouseBinding Command="{Binding DataContext.MonthItemDoubleClick,ElementName=MonthlySchedule}" MouseAction="LeftDoubleClick" CommandParameter="{Binding ElementName=Item}"/>
</local:MonthItem.InputBindings>
这里面 local:monthitem 是我的自义定控件 所以可以替换成任何控件 主要是 MouseBinding代码 ElementName 指定的是窗体的名字
全部代码
<ItemsControl Margin="0" ItemsSource="{Binding Warplist}" VerticalAlignment="Bottom" Grid.Row="1" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ItemHeight="136" ItemWidth="215" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:MonthItem x:Name="Item" No="{Binding NO}" MonthScheduleModel="{Binding MonthScheduleModel}" IsTrue="{Binding IsTrue}">
<local:MonthItem.InputBindings>
<MouseBinding Command="{Binding DataContext.MonthItemDoubleClick,ElementName=MonthlySchedule}" MouseAction="LeftDoubleClick" CommandParameter="{Binding ElementName=Item}"/>
</local:MonthItem.InputBindings>
</local:MonthItem>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>