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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:45:57+00:00 2026-05-21T04:45:57+00:00

I’ve created a button control template where I want to change the color of

  • 0

I’ve created a button control template where I want to change the color of the button depending on the mode of the button (whether its in Go mode or Stop mode). The XAML looks like :

                        </LinearGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
                <Ellipse x:Name="innerCircle" RenderTransformOrigin=".5,.5">
                    <Ellipse.RenderTransform>
                        <ScaleTransform ScaleX=".8" ScaleY=".8"/>
                    </Ellipse.RenderTransform>
                    <Ellipse.Fill>
                        <LinearGradientBrush  StartPoint="0,0" EndPoint="0,1">
                            <GradientStopCollection>
                                <GradientStop Offset="0" Color="Green"/>
                                <GradientStop Offset="1" Color="Transparent"/>
                            </GradientStopCollection>

                        </LinearGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
                <Viewbox>
                    <ContentPresenter Margin="{TemplateBinding Padding}"/>
                </Viewbox>
            </Grid>
            <ControlTemplate.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsGo}" Value="True">
                    <Setter TargetName="outerCircle" Property="Fill">
                        <Setter.Value>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                <GradientStopCollection >
                                    <GradientStop Offset="0" Color="White"/>
                                    <GradientStop Offset="1" Color="Red"/>
                                </GradientStopCollection>

                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter TargetName="innerCircle" Property="Fill">
                        <Setter.Value>
                            <LinearGradientBrush  StartPoint="0,0" EndPoint="0,1">
                                <GradientStopCollection>
                                    <GradientStop Offset="0" Color="Red"/>
                                    <GradientStop Offset="1" Color="Transparent"/>
                                </GradientStopCollection>

                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>

            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Grid.Resources>        
        <Button Background="Transparent" Content="STOP" Padding="10" Template="{StaticResource buttonTemplate}" Height="84" Width="87" Click="Button_Click"></Button>       
</Grid>

In my DataTrigger i have a binding to a IsGo DP property which i have defined in the code behind (of type boolean). I have a click handler which toggles the state of this DP in the code behind :

  /// <summary>
    /// Interaction logic for GoButton.xaml
    /// </summary>
    public partial class GoButton
    {
        public GoButton()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty IsGOProperty = DependencyProperty.Register("IsGo", typeof(Boolean), typeof(GoButton), new PropertyMetadata(false));

        public Boolean IsGo
        {
            get { return (Boolean)GetValue(IsGOProperty); }
            set { SetValue(IsGOProperty, value); }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            IsGo = !IsGo;
        }
    }

However, when i click my button, nothing happens – although the click handler code executes and toggles the DP property, the colour of the button stays green and doesn’t change to red. Any ideas what i’m doing wrong ?

thanks

  • 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-21T04:45:58+00:00Added an answer on May 21, 2026 at 4:45 am

    Your TemplatedParent is (I’m guessing) the button you’re templating. The codebehind where you’ve defined your property most likely isn’t a control derived from button, so I’m guessing your trigger’s binding is incorrect…

    If you could post the rest of your XAML and/or confirm which codebehind your property is in, this could be confirmed.

    EDIT: Your comment confirms my theory: you’re binding to TemplatedParent but the property isn’t on TemplatedParent, it’s on your usercontrol. The easist solution is to add a x:Name="root" tag to your UserControl‘s root element, and then change the trigger’s binding to {Binding ElementName=root, Path=IsGo}.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I want to construct a data frame in an Rcpp function, but when I

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.