Checked status not updated in CheckBox template
Posted
by Simon
on Stack Overflow
See other posts from Stack Overflow
or by Simon
Published on 2010-06-13T10:51:16Z
Indexed on
2010/06/13
10:52 UTC
Read the original article
Hit count: 331
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?
© Stack Overflow or respective owner