Tim Hibbard

Software Architect for EnGraph software


News





Add to Google



My Stats

  • Posts - 593
  • Comments - 353
  • Trackbacks - 507

Twitter












Tag Cloud


Recent Comments


Recent Posts


Article Categories


Archives


Post Categories


Image Galleries


EnGraph Blogs


Links


Other


Roll



I don't think the WPF ToogleButton has a distinct visual difference between it's checked and unchecked state.  So I wanted to change the text displayed when the button was checked.  So I created a trigger that looked at the IsChecked property and changed the content property accordingly.  However, the default template of a ToggleButton changes it's appearance when it is checked, so certain properties are not written as expected.  To fix this, I set the content property in the styles of the toggle button and it worked.  Here is the code:
<ToggleButton Name="showStopsCheckBox">
    <ToggleButton.Style>
        <Style TargetType="{x:Type ToggleButton}">
            <Setter Property="Content" Value="Stops"/>
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Content" Value="Trips"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </ToggleButton.Style>
</ToggleButton>

posted @ Tuesday, May 13, 2008 11:54 AM | Filed Under [ .NET WPF ]

Comments

No comments posted yet.
Post a comment





 

Please add 7 and 2 and type the answer here: