我有一个这样定义的列表视图(建立在列表视图顶部并允许排序的类)
<vm:JobListView x:Name="JobEditor"
Style="{DynamicResource JobEditListViewStyle}"
ItemContainerStyle="{DynamicResource JobEditListViewItemStyle}"
ItemsSource="{Binding Path=Jobs}"
SelectedItem="{Binding Path=SelectedJob, Mode=TwoWay}">
<vm:JobListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<GridViewRowPresenter>
<GridViewRowPresenter.InputBindings>
<MouseBinding Gesture="LeftClick" Command="{Binding DataContext.SearchJobVM_OnSelectionChanged, RelativeSource={RelativeSource AncestorType={x:Type Window}}, Mode=OneWay}" CommandParameter="{Binding SelectedJob}" />
</GridViewRowPresenter.InputBindings>
</GridViewRowPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</vm:JobListView.ItemContainerStyle>
事件很好地冒泡,但命令参数作为null传递给视图控制器中的方法
有什么想法吗?
注意-如果我完全删除ItemContainerStyle,可以看到绑定的SelectedJob确实被设置了