mercredi 22 avril 2015

Using eventtrigger without clicking

I have a CheckBox that's set up like so:

    <CheckBox x:Name="ViewTypeCheckbox" IsChecked="{Binding ViewType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Click">
                <i:InvokeCommandAction Command="{Binding Refresh}"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </CheckBox>

This functions as it's supposed to. When checked or unchecked by mouse click, the command is fired in the ViewModel.

You see the checkBox is databound to a bool property ("ViewType") that regularly turns from true to false and viseversa in response to user input.

The problem is I need the EventTrigger to fire when checked or unchecked by the ViewModel.

I've tried changing the "EventName" to "Checked", "IsChecked" and "UnChecked" but that doesn't seem to do anything.

Is there any additional code I need to implement? How would I get this to work?




Aucun commentaire:

Enregistrer un commentaire