I have a CheckBox, which I have defined in my xaml file with the help of a Windows.UI.Xaml.Controls.ControlTemplate. I have done this because I needed to overwrite the existing CheckBox image. Here is my CheckBox:
<CheckBox Grid.Column="1" Width="30" Height="30" HorizontalAlignment="Center" Checked="CheckBox_Checked">
<CheckBox.Template>
<ControlTemplate TargetType="CheckBox">
<Image Source="Assets/unchecked_checkbox.png"/>
</ControlTemplate>
</CheckBox.Template>
</CheckBox>
So, that works. But now when I want to change the image when the user checks the CheckBox, I assume I have to do it in code-behind. I tried to create a template but...
ControlTemplate ctr = new ControlTemplate();
ctr.TargetType = typeof(CheckBox);
ctr.
as you can see I'm stuck. The only thing that pops up here is SetValue, but this needs a parameter of type DependencyProperty as well as an object.
I need help...
Aucun commentaire:
Enregistrer un commentaire