Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8563707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:01:21+00:00 2026-06-11T17:01:21+00:00

I am trying the distinguish the state of the toggle button when clicked. I

  • 0

I am trying the distinguish the state of the toggle button when clicked. I have the snippet below

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style x:Key="OnOffToggleImageStyle" TargetType="ToggleButton">
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Background" Value="DimGray"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <ToggleButton Height="60" Content="Text" Style="{StaticResource OnOffToggleImageStyle}">
        </ToggleButton>
    </Grid>
</Window>

However this does not work when IsChecked value is set to “True” in the style. When set to false it works.

I wonder why. Any answers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:01:22+00:00Added an answer on June 11, 2026 at 5:01 pm

    When running your code sample, it appears the style is conflicting with the ‘chrome’ of the ToggleButton (i.e. the original style of the button).

    It would probably be better in this situation to override the template of the ToggleButton to behave in the manner you desire. An ugly example can be found below:

    <Style x:Key="myToggleButton" TargetType="{x:Type ToggleButton}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate>
            <Border x:Name="outer"
            BorderBrush="White"
            BorderThickness="2"
            Opacity=".9"
            Background="Transparent">
              <Border x:Name="inner"
              Margin="8"
              BorderThickness="0"
              Background="{
                Binding Background, 
                RelativeSource={RelativeSource TemplatedParent}}">
                <Grid x:Name="container">
                  <Grid.RowDefinitions>
                    <RowDefinition Height="2*"/>
                    <RowDefinition/>
                  </Grid.RowDefinitions>
                  <TextBlock x:Name="display"
                  Grid.Row="1"
                  Text="{Binding Content, RelativeSource={
                    RelativeSource TemplatedParent}}"
                  Foreground="White"
                  FontSize="11"
                  FontFamily="Segoe UI"
                  FontStyle="Normal"
                  FontWeight="Normal"
                  Margin="8,0,0,4"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Bottom"/>
                </Grid>
              </Border>
            </Border>
            <ControlTemplate.Triggers>
              <Trigger Property="ToggleButton.IsChecked" Value="True">
                <Setter TargetName="outer" Property="Background" Value="LightBlue"/>
                <Setter TargetName="outer" Property="BorderBrush" Value="Transparent"/>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a button to show / hide a div below it,
I am trying to distinguish which button/link was pressed on the submit. I am
I'm trying to find a CSS selector that can help me distinguish between the
trying to figure out why this is happening - I have an input text
Trying to learn F# but got confused when trying to distinguish between fold and
I'm trying my hand at jQuery Address http://www.asual.com/jquery/address/ On a click event I set
I'm trying to find the top-level widget on a non-active window. But I do
I am trying to use the KeychainWrapper class provided in this Apple sample code:
I'm trying to distinguish if an activity is destroyed then restarted vs. when it's
In XSL 1.0, I am trying to distinguish between the following 2 scenarios which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.