vendredi 1 mai 2015

WPF CheckBox UnCheck Event Not Firing

I have a checkbox inside an ItemsControl. It has an EventTrigger both for Checked and UnChecked events. It is also bound to a Command with multiple CommandParameters. The Checked event triggers just fine.

However, the UnChecked event does not fire. What am I missing?

    <ItemsControl Grid.Column ="2" 
                  Grid.Row    ="0" 
                  ItemsSource ="{Binding ParameterOptionGroup.ParameterOptions}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <CheckBox IsChecked="{Binding State, Converter={StaticResource BoolToEntityState}, Mode=OneWay}">
                    <trigger:Interaction.Triggers>
                        <trigger:EventTrigger EventName="Checked">
                            <trigger:InvokeCommandAction  Command ="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, 
                                                             Path=DataContext.InitiateParameterAnswer}">
                                <trigger:InvokeCommandAction.CommandParameter>
                                    <MultiBinding Converter="{StaticResource GuidAndParameterOptionToTuple}">
                                        <Binding Path="DataContext" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}"></Binding>
                                        <Binding Path="DataContext.Id" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}"></Binding>
                                        <Binding Path="Text" ElementName="txtRemarks" />
                                        <Binding Source="True" />
                                        <Binding Source="10" />
                                    </MultiBinding>
                                </trigger:InvokeCommandAction.CommandParameter>
                            </trigger:InvokeCommandAction>
                        </trigger:EventTrigger>
                    </trigger:Interaction.Triggers>
                    <trigger:EventTrigger EventName="UnChecked">
                        <trigger:InvokeCommandAction  Command ="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, 
                                                             Path=DataContext.InitiateParameterAnswer}">
                            <trigger:InvokeCommandAction.CommandParameter>
                                <MultiBinding Converter="{StaticResource GuidAndParameterOptionToTuple}">
                                    <Binding Path="DataContext" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}"></Binding>
                                    <Binding Path="DataContext.Id" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}"></Binding>
                                    <Binding Path="Text" ElementName="txtRemarks" />
                                    <Binding Source="False" />
                                    <Binding Source="5" />
                                </MultiBinding>
                            </trigger:InvokeCommandAction.CommandParameter>
                        </trigger:InvokeCommandAction>
                    </trigger:EventTrigger>
                </CheckBox>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>




Aucun commentaire:

Enregistrer un commentaire