Checked status not updated in CheckBox template
- by Simon
Hey there.
I'm trying to create an hyperlink that changes its text depending on a boolean value. I thought I could leverage the IsChecked method of a CheckBox. So I wrote this ControlTemplate for a CheckBox:
<CheckBox Checked="CheckBox_Checked" IsChecked="{Binding Path=SomeBool, Mode=TwoWay}">
<CheckBox.Template>
<ControlTemplate TargetType="{x:Type CheckBox}">
<BulletDecorator>
<BulletDecorator.Bullet>
<TextBlock>
<Hyperlink>
<TextBlock x:Name="TextBoxHyperlink">Unchecked</TextBlock>
</Hyperlink>
</TextBlock>
</BulletDecorator.Bullet>
<ContentPresenter />
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="TextBoxHyperlink"
Property="Text"
Value="Checked" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</CheckBox.Template>
</CheckBox>
But when I click on the hyperlink, nothing happens. The checked status is not changed and the Text property of the TextBlock is not updated. Any ideas?