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 8523373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:23:29+00:00 2026-06-11T07:23:29+00:00

I have a ToggleButton in my window and styled in my ResourceDictionary. The reason

  • 0

I have a ToggleButton in my window and styled in my ResourceDictionary. The reason why it’s in the ResourceDictionary is because I have several or more ToggleButton soon which has to have the same look.

<Style x:Key="Standardbutton" TargetType="{x:Type ToggleButton}">
    <Setter Property="FontSize" Value="18" />
    <Setter Property="Foreground" Value="White" />
    <Setter Property="Background">
        <Setter.Value>
            <ImageBrush ImageSource="Resources/Standard_Button_Normal.png" />
        </Setter.Value>
    </Setter>
    <Setter Property="Height" Value="56" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ToggleButton">
                <Border Name="border" BorderThickness="0" Padding="0,0" BorderBrush="DarkGray" CornerRadius="0" Background="{TemplateBinding Background}">
                    <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" Name="content" Margin="15,0,0,0"/>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsChecked" Value="True">
                        <Setter Property="Background">
                            <Setter.Value>
                                <ImageBrush ImageSource="Resources/Standard_Button_Pressed.png" />
                            </Setter.Value>
                        </Setter>
                        <Setter Property="Foreground">
                            <Setter.Value>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFF9CE7B" Offset="0"/>
                                    <GradientStop Color="#FFE88C41" Offset="1"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Now this ToggleButton style has a default background and also when “IsChecked” is true, it will have different background (as you can see on my XAML code above).

Now these toggle buttons has to have icon + text combined, like what I did here (sorry for my lame XAML code)

<ToggleButton Style="{DynamicResource Standardbutton}" Margin="0,0,0,4">
    <StackPanel Orientation="Horizontal">
        <Image Source="Resources/scan_26x26.png" />
        <TextBlock Text="Scan"/>
    </StackPanel>
</ToggleButton>

The question is, how can I have a different icon when the ToggleButton is checked (IsChecked=True)?

Here are some images that might help you to understand the question

Normal ToggleButton Style
enter image description here
IsChecked=True Style
enter image description here
My design goal is to have a different icon when IsChecked=True
enter image description here

  • 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-11T07:23:31+00:00Added an answer on June 11, 2026 at 7:23 am

    Add both images to the control template, and bind their Visibility property to the IsChecked property (use an IValueConverter to convert from true/false to the appropriate Visibility enum value).

    <ToggleButton Style="{DynamicResource Standardbutton}" Margin="0,0,0,4">
        <StackPanel Orientation="Horizontal">
            <Image Source="Resources/scan_26x26.png" 
                   Visibility="{Binding 
                      RelativeSource={RelativeSource AncestorType=ToggleButton},
                      Path=IsChecked,
                      Converter={StaticResource BoolToVisibleConverter}}" />
            <Image Source="Resources/anotherimage.png" 
                      Visibility="{Binding 
                         RelativeSource={RelativeSource AncestorType=ToggleButton},
                         Path=IsChecked,
                         Converter={StaticResource BoolToCollapsedConverter}}" />
            <TextBlock Text="Scan"/>
        </StackPanel>
    </ToggleButton>
    

    I used two converters BoolToVisibleConverter and BoolToCollapsedConverter, but you could also use a ConverterParameter to accomplish the same thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ToggleButton to which I'm applying the following style <Style x:Key=ToggleButtonStyle TargetType=ToggleButton>
Have deployed numerous report parts which reference the same view however one of them
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have a TreeView with a ToggleButton ( ExpanderButton ). The togglebutton has a
i have a native win32 c++ application which has a checkbox in it. I
I have a datagrid and in DataGridTemplateColumn, I have a togglebutton which when checked,
I have a togglebutton which is not responding to my setChecked(...) method. Here is
I have included the following style for ComboBox , which I happened to find
I have a GWT 2.0 ToggleButton that I have styled from a ResourceBundle: ToggleButton
I have a FrameworkElement (really a ToggleButton ) that has inside its content a

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.