I created a custom checkbox using a UserControl with Image and Label inside. I want to swap the Checked and Unchecked images whenever i click it. So far i tried doing the following
<Image Source="{Binding StateImage}"/>
I have a property named StateImage
public String StateImage
{
get
{
return is_checked?"{StaticResource Checked}":"StaticResource Unchecked";
}
}
My code doesn't work and i ended up doing like this:
public String StateImage
{
get
{
return is_checked?"/Resources/Images/Checked.png":"/Resources/Images/Unchecked.png";
}
}
the is_checked variable is modified under MouseDown Event of the UserControl
Is there an easier way I can call the image without writing the whole path and filename?
UserControland create a custom control based onCheckbox, have different image properties for each state and swap the images viaControlTemplate.Triggers. However, this suggestion is a bit far from your question, so I don't feel like it should be a full blown answer for now.