KaJo
KaJo

Reputation: 199

WPF: Can I restyle a checkbox template, so that the checkindicator is a red cross instead

I can´t find a way to restyle the IsChecked indicator of a checkbox. As I can see from the checkbox template there´s no possibilities to restyle the indicator, just the "box" of the checkbox. Does anyone knows if it´s possibly to restyle the IsChecked indicator?

Upvotes: 2

Views: 7621

Answers (2)

Nir
Nir

Reputation: 29584

You will have to replace the entire CheckBox control template.

Start with the ChekcBox ControlTemplate MSDN example at http://msdn.microsoft.com/en-us/library/ms752319.aspx

In the example you'll see this element:

<Path 
Width="7" Height="7" 
x:Name="CheckMark"
SnapsToDevicePixels="False" 
Stroke="{StaticResource GlyphBrush}"
StrokeThickness="2"
Data="M 0 0 L 7 7 M 0 7 L 7 0" />

This is the indicator, in this sample the indicator is already an X, so change Stroke to Red and You're done.

To change the shape of the indicator change the Path's Data property.

Upvotes: 5

stusmith
stusmith

Reputation: 14103

You might find the following discussion helpful:

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f8e3c903-5c82-46ec-a065-9a75d9f79b75/

People describe various ways of extracting or viewing the standard WPF control templates.

Upvotes: 1

Related Questions