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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:23:53+00:00 2026-06-04T16:23:53+00:00

I have created a style which defines a common look for a control. This

  • 0

I have created a style which defines a common look for a control. This includes a RadialGradientBrush, and a border with a corner radius.

I apply this style to the relevant Border controls that I want to look like this.

Within the style, I indicate the 3 colours for the RadialGradientBrush, however, I want to be able to make one of the colours specified pick up the colour from the actual Border control.

<Style x:Key='ButtonStyle' TargetType='Border'>
    <Setter Property='CornerRadius' Value='10' />
    <Setter Property='Margin' Value='2' />
    <Setter Property='BorderThickness' Value='1'/>
    <Setter Property='BorderBrush' Value='White'/>
    <Setter Property='Background'>
        <Setter.Value>
            <RadialGradientBrush >
                <GradientStop Color='DarkBlue' Offset='0.9'/>
                <GradientStop Color='White' Offset='0.7'/>
                <GradientStop Color='Black' Offset='0.3' />
            </RadialGradientBrush>
        </Setter.Value>
    </Setter>
</Style>

So, where it says DarkBlue in the <Style> I want it to say something like Control.Backcolor. Then it will use the background colour defined in the actual control to replace this value.

Hope that makes sense.
Thanks
Rich.

  • 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-04T16:23:54+00:00Added an answer on June 4, 2026 at 4:23 pm

    You could solve it this way:

        <Grid>
        <Grid.Resources>
          <local:ColorConverter x:Key="myColorConverter"/>
          <Style x:Key="ButtonStyle" TargetType="{x:Type Border}">
            <Setter Property="CornerRadius" Value="10" />
            <Setter Property="Margin" Value="2" />
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Background">
              <Setter.Value>
                <RadialGradientBrush >
                  <GradientStop Color="{Binding Path=BorderBrush,Converter={StaticResource myColorConverter}, RelativeSource={RelativeSource AncestorType={x:Type Border}}}" Offset="0.9" />
                  <GradientStop Color='White' Offset='0.7'/>
                  <GradientStop Color='Black' Offset='0.3' />
                         </RadialGradientBrush>
              </Setter.Value>
            </Setter>
          </Style>
    
        </Grid.Resources>
          <StackPanel x:Name="myStackPanel">
            <Border x:Name="myBorder1" Style="{StaticResource ButtonStyle}" BorderBrush="Yellow" Height="25"></Border>
            <Border x:Name="myBorder2" Style="{StaticResource ButtonStyle}" BorderBrush="Green" Height="25"></Border>
          </StackPanel>
      </Grid>
    

    And you need a converter to access the brush’s color.

      public class ColorConverter : IValueConverter
      {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
          if (value is SolidColorBrush)
          {
            var brush = value as SolidColorBrush;
            return brush.Color;
          }
          return null;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
          throw new NotImplementedException();
        }
      }
    

    In this sample I use the BorderBrush of the border to be the outmost color for your RadialGradientBrush. You can’t use the Background property here as it would override the value set by the style.
    A cleaner solution would be to derive your own Border and create DependencyProperties for your distinct color values …

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

Sidebar

Related Questions

I have a engine style Rails plugin from which I can create a gem
I have created tab style interface using css and javascript with only two tabs
I have created a default style for a Button including a custom ControlTemplate like
I have created a custom style and template for MenuItem and ContextMenu, and for
I have a simple style for label controls. I'd like to define a control
I have the following Style (defined as a Resource in xaml). This is basically
I understand that to apply a style you have to create the textview and
Currently, I'm able to load in a static sized texture which I have created.
I have a dependency property (Foreground) on a custom control which is inheriting from
I have created a model and store in which read in a json file

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.