tags:

views:

753

answers:

1
+6  A: 

I'm not sure I fully understand your questions, but let me try. It all matters how deep you want to go here, too. There are many ways to skin this cat.

1 - I think you're asking how to use the IsChecked property to influence the look of the CheckBox? The way to do this is re-template the CheckBox and use a trigger in the template. Something like this:

<CheckBox>
    <CheckBox.Template>
        <ControlTemplate TargetType="CheckBox">
            <StackPanel Orientation="Horizontal">
                <Image x:Name="_image" Source="Unchecked.jpg"/>
                <ContentControl Content="{Binding Content}"/>
            </StackPanel>
            <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter ElementName="_image" Property="Source" Value="Checked.jpg"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </CheckBox.Template>
</CheckBox>

There is more to consider here, but that should get you started.

2 - You can use InputBindings to execute a command when some input is received by the control. So you can define a command that checks or unchecks the appropriate CheckBox based on the parameter passed to the command. Then you can do something like this:

<CheckBox>
    <CheckBox.InputBindings>
        <KeyBinding Key="1" Command="{x:Static local:Commands.YourCommand}" CommandParameter="1"/>
    </CheckBox.InputBindings>
</CheckBox>

Again, there are many ways to solve your problems here. Hopefully this steers you in the right direction.

HTH, Kent

Kent Boogaart
thx for this ! beginning to understand :)
Bernhard