I'm trying to customize the look of a checkbox in WPF. I was hoping I could grab the default control template for the BulletChrome class that's defined in PresentationFramework.Aero and work with that. However, BulletChrome is not a sublcass of Control, so there's no template to modify. Does anyone know I could do this?
You don't want to do this. Changing the control template is not supposed to change the behavior of the control, and a CheckBox control, by definition has three states (Checked, Unchecked, Indeterminate).
You're better off creating a custom 4-state (or n-state if you prefer) Control that borrows alot of Look/Feel from the CheckBox ControlTemplate.
If BulletChrome is not customisable, you can't customise it. But you definitely can replace it with something that is customisable.
In practical terms I would suggest starting with Silverlight's theme instead of Aero.
If you want to place some sort of BulletChrome in CheckBox' Template where the BulletDecorator in the classic Template would go, you could do that, since BulletChrome inherits from Decorator, which inherits from FrameworkElement.
The next part, how does the BulletChrome get its looks? Well, this is one of the rare parts from WPF where they handle rendering completely without xaml: The ButtonChrome's visual appearance is defined in its OnRender()
method.
BulletChrome.OnRender(), from Reflector:
protected override void OnRender(DrawingContext drawingContext)
{
Rect bounds = new Rect(0.0, 0.0, base.ActualWidth, base.ActualHeight);
this.DrawBackground(drawingContext, ref bounds);
this.DrawDropShadows(drawingContext, ref bounds);
this.DrawBorder(drawingContext, ref bounds);
this.DrawInnerBorder(drawingContext, ref bounds);
}
Unfortunately, since all these methods called inside OnRender() are private, you can't mess with them even if you subclass the ButtonChrome, perhaps only overlay some of your rendering on top.
So basically, you either start digging trough rendering code in Reflector and try to adapt and rewrite it to your needs, or roll your own Template/Decorator/whatever from scratch. (But then it really isn't important what you use as long as it works, right?)
Hope this answered your question, cheers.