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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:25:23+00:00 2026-05-22T19:25:23+00:00

I had created a button and i want to change its color using style

  • 0

I had created a button and i want to change its color using style from app xaml.
But,i don’t get the exact code and i am new to xaml.

Can any one help me with some example.

I am also confused to use which property to change color means background or foreground?

  • 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-05-22T19:25:24+00:00Added an answer on May 22, 2026 at 7:25 pm
    <Window
      x:Class="ToolBar"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="ToolBar"
      Width="300"
      Height="300">
      <DockPanel>
        <ToolBarTray
          DockPanel.Dock="Top"
          IsLocked="True"
          Orientation="Horizontal">
          <ToolBar
            x:Name="ToolBar1">
            <ToggleButton>
              <ToggleButton.Style>
                <Style
                  TargetType="{x:Type ToggleButton}">
                  <Setter Property="ContentTemplate">
                    <Setter.Value>
                      <DataTemplate>
                        <Label>Play</Label>
                      </DataTemplate>
                    </Setter.Value>
                  </Setter>
                  <Style.Triggers>
                    <Trigger Property="IsChecked" Value="True">
                      <Setter Property="ContentTemplate">
                        <Setter.Value>
                          <DataTemplate>
                            <Label>Pause</Label>
                          </DataTemplate>
                        </Setter.Value>
                      </Setter>
                      <Setter Property="BorderBrush" Value="Transparent" />
                      <Setter Property="Panel.Background" Value="Transparent" />
                    </Trigger>
                  </Style.Triggers>
                </Style>
              </ToggleButton.Style>
            </ToggleButton>
          </ToolBar>
        </ToolBarTray>
      </DockPanel>
    </Window>
    

    Within a toolbar, the two statements:

    <Setter Property="BorderBrush" Value="Transparent" />
    <Setter Property="Panel.Background" Value="Transparent" />
    

    causes the toggle button to appear in the normal state when the toggle button is checked, however nothing changes when you hover over the checked toggle button.

    If I wrap the toggle button in another layout, say wrap layout:

    <Window
      x:Class="ToolBar"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="ToolBar"
      Width="300"
      Height="300">
      <WrapPanel>
            <ToggleButton>
              <ToggleButton.Style>
                <Style
                  TargetType="{x:Type ToggleButton}">
                  <Setter Property="ContentTemplate">
                    <Setter.Value>
                      <DataTemplate>
                        <Label>Play</Label>
                      </DataTemplate>
                    </Setter.Value>
                  </Setter>
                  <Style.Triggers>
                    <Trigger Property="IsChecked" Value="True">
                      <Setter Property="ContentTemplate">
                        <Setter.Value>
                          <DataTemplate>
                            <Label>Pause</Label>
                          </DataTemplate>
                        </Setter.Value>
                      </Setter>
                      <Setter Property="BorderBrush" Value="Transparent" />
                      <Setter Property="Panel.Background" Value="Transparent" />
                    </Trigger>
                  </Style.Triggers>
                </Style>
              </ToggleButton.Style>
            </ToggleButton>
      </WrapPanel>
    </Window>
    

    the two statements:

    <Setter Property="BorderBrush" Value="Transparent" />
    <Setter Property="Panel.Background" Value="Transparent" />
    

    You can find tutorial in the folowing url
    http://social.msdn.microsoft.com/Forums/pl-PL/wpf/thread/7e565a41-0aad-40a3-a3c4-666c5caf38fe

    Thanks
    Deepak

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

Sidebar

Related Questions

In one of my builds for an iPhone app, I had inadvertently created a
On my previous machine I had IIS6 installed and created a web project using
I have created a custom Button class and I want to be able to
I am using MVVM architecture. I had created a user control which contains a
I created a pretty fancy winforms app for my company. We had a graphic
I had created one HTML page for my experiance. In this i had use
I had created a zip file (together with directory) under Windows as follow (Code
Doug McCune had created something that was exactly what I needed ( http://dougmccune.com/blog/2007/05/10/analyze-your-actionscript-code-with-this-apollo-app/ )
I have a smallish utility library I made that I had created in TFS
If a set of controls on a WinForm have had DataBindings created and attached

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.