I want to have custom checkboxes in my application with images instead of the normal box. I also need to have different images depending on the checkbox so I thought I'd use a binding in my custom checkbox class to a class that has the images.
The C# code for my custom checkbox.
public class LogoCheckBox : CheckBox
{
private Service _service;
public Service Service
{
get { return (Service)GetValue(ServiceProperty); }
set
{
SetValue(ServiceProperty, value);
UncheckedImage = value.OtherLogo;
CheckedImage = value.Logo;
}
}
public static readonly DependencyProperty ServiceProperty =
DependencyProperty.Register("Service", typeof(Service), typeof(LogoCheckBox));
public ImageSource UncheckedImage { get; private set; }
public ImageSource CheckedImage { get; private set; }
public LogoCheckBox()
{
}
void CheckedHandler(object sender, RoutedEventArgs e)
{
//Change displayed image
}
}
I'm pretty stumped when it comes to styling the thing in XAML so I have the wanted behaviour.
My question is basically: Am I on the right track (this is a good way to achieve the functionality) and if it is how do I style it properly?
Aucun commentaire:
Enregistrer un commentaire