DataTemplate 中的 wpf CheckBox 命令

wpf CheckBox Command in a DataTemplate

我有一个这样的数据模板:

<DataTemplate x:Key="CheckBoxDataTemplate">
    <CheckBox IsChecked="{Binding 
              Path=IsSelected, Mode=TwoWay}" 
              HorizontalAlignment="Center" 
              VerticalAlignment="Center" Name="aDM_LEVEL_FIELDListView" Path="SelectedItem">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Checked">
                <WPFCtlr:EventToCommand Command="{Binding DataContext.UnCheckCommand, RelativeSource={RelativeSource FindAncestor,ListView,1}}" CommandParameter="{Binding ElementName=_thisChk}" />
                <!--<i:InvokeCommandAction Command="{Binding Path=SelectItemRelayCommand}" />-->
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </CheckBox>
    <!--Command="{Binding Path=DataContext.UnCheckCommand}" 
              CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />-->
</DataTemplate>

这是模板选择器:

<TemplateSelector:PropertyDataTemplateSelector x:Key="templateSelector"
      BooleanDataTemplate="{StaticResource CheckBoxDataTemplate}" 
      IsEnum="IsExclusive"/>

这是引用模板的ListView

<ListView   Grid.Row="1"
    ItemsSource="{Binding Path=FilteredLevelFields}"
    Margin="5,10,5,5" 
    Name="aDM_LEVEL_FIELDListView" 
    SelectionMode="Single"
    FontSize="13"
    Background="AliceBlue"
    BorderBrush="AliceBlue" 
    SelectedItem="{Binding Path=CurrentElement}">

    <!--Style of items-->
        <ListView.ItemContainerStyle>
            <Style TargetType="{x:Type ListViewItem}">
                <!--Properties-->
                <Setter Property="Control.HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="Control.VerticalContentAlignment" Value="Center" />
                <!--Trigger-->
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="Background" Value="{x:Null}" />
                        <Setter Property="BorderBrush" Value="{x:Null}" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ListView.ItemContainerStyle>

        <ListView.View>
            <GridView ColumnHeaderContainerStyle="{StaticResource GridViewColumnHiddenHeaderStyle}">
                <GridViewColumn Header="ID LEVEL FIELD" CellTemplate="{StaticResource FatherTemplate}" Width="300"/>
                <GridViewColumn Header="Value" CellTemplateSelector="{StaticResource templateSelector}" Width="80" />
                <GridViewColumn Header="ID LEVEL FIELD" CellTemplate="{StaticResource DetailIdenTemplate}" Width="300"/>
            </GridView>
        </ListView.View>
</ListView>

这是我的 ViewModel 中的命令:

RelayCommand _unCheckCommand;
public ICommand UnCheckCommand
{
    get
    {
        if (_unCheckCommand == null)
        {
            _unCheckCommand = new RelayCommand(
                param => this.UnCheck(param),
                param => this.CanUnCheck
            );
        }
        return _unCheckCommand;
    }
}

我的目标是将列表视图中的元素 I select 作为参数传递给命令。我该怎么做?

我自己做的:

<DataTemplate x:Key="CheckBoxDataTemplate">
    <CheckBox IsChecked="{Binding 
              Path=IsSelected, Mode=TwoWay}" 
              HorizontalAlignment="Center" 
              VerticalAlignment="Center" Name="aDM_LEVEL_FIELDListView" Path="SelectedItem" >
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Checked">
                <WPFCtlr:EventToCommand Command="{Binding DataContext.UnCheckCommand, RelativeSource={RelativeSource FindAncestor,ListView,1}}" CommandParameter="{Binding ElementName=aDM_LEVEL_FIELDListView, Path=SelectedItem}" />
                <!--<i:InvokeCommandAction Command="{Binding Path=SelectItemRelayCommand}" />-->
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </CheckBox>
    <!--Command="{Binding Path=DataContext.UnCheckCommand}" 
              CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />-->
</DataTemplate>