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

  • Home
  • SEARCH
  • 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 274467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:36:53+00:00 2026-05-12T00:36:53+00:00

My problem is certainly right on my face but I can’t see it… I

  • 0

My problem is certainly right on my face but I can’t see it…

I am building a very simple user control – a 3D ellipse – and I expose two properties: LightColor and DarkColor. I need to bind these properties to the gradient in my user control, but it is not showing any color at all. Here’s my usercontrol:

<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestBrushes"
mc:Ignorable="d"
x:Class="TestBrushes._3DEllipse"
x:Name="UserControl"
d:DesignWidth="200" d:DesignHeight="200">
    <Grid x:Name="LayoutRoot">
        <Ellipse Name="MainEllipse" Stroke="{x:Null}">
            <Ellipse.Fill>
                <RadialGradientBrush GradientOrigin="0.5,1.1">
                    <GradientStop Color="{Binding ElementName=UserControl, Path=LightColor}" Offset="1"/>
                    <GradientStop Color="{Binding ElementName=UserControl, Path=DarkColor}"  Offset="0"/>
                </RadialGradientBrush>
            </Ellipse.Fill>
        </Ellipse>
        <Ellipse Name="TopReflectionEllipse" Stroke="{x:Null}" Margin="38,0,38,0" VerticalAlignment="Top" Height="90">
            <Ellipse.Fill>
                <RadialGradientBrush GradientOrigin="0.5,0">
                    <RadialGradientBrush.RelativeTransform>
                        <TransformGroup>
                            <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1" ScaleY="1"/>
                            <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
                            <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/>
                            <TranslateTransform X="0" Y="0"/>
                        </TransformGroup>
                    </RadialGradientBrush.RelativeTransform>
                    <GradientStop Color="#A5FFFFFF" Offset="0"/>
                    <GradientStop Color="#00FFFFFF" Offset="1"/>
                </RadialGradientBrush>
            </Ellipse.Fill>
        </Ellipse>
    </Grid>
</UserControl>

and here’s my code-behind:

public partial class _3DEllipse
{
    public _3DEllipse()
    {
        InitializeComponent();
    }

    public Color DarkColor { get; set; }
    public Color LightColor { get; set; }
}

If I assign colors as opposed to the binding shown in the code, it works ok, but I want to use the properties I am exposing. What am I 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-12T00:36:54+00:00Added an answer on May 12, 2026 at 12:36 am

    Your issue is likely that you aren’t notifiying the UserControl of changes made to the value of the DarkColor and LightColor properties. To do so you’ll need to implement the INotifyPropertyChanged interface. The purpose of this interface is to make UI components aware of when the value they’re bound to is updated; they subscribe to the PropertyChanged event that is exposed by implementing the interface.

    A sample implementation is below, I’ve left the DarkColor property alone, but it would be updated in the same fashion.

    public partial class _3DEllipse : INotifyPropertyChanged
    {
    
        private Color _lightColor;
    
    
        public _3DEllipse()
        {
            InitializeComponent();
        }
    
        // interface implementation
        public event PropertyChangedEventHandler PropertyChanged;
    
        public Color DarkColor { get; set; }
        public Color LightColor
        {
            get { return _lightColor; }
            set
            {
                // only update value if its changed
                if ( _lightColor == value )
                {
                    return;
                }
    
                _lightColor = value;
                OnPropertyChanged("LightColor");
            }
        }
    
        protected virtual void OnPropertyChanged(string propertyName)
        {
            if ( PropertyChanged == null ) return;
    
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Certainly there is no one right way to do this, but I can't even
Based on the answer from axtavt, this is almost certainly a naming problem between
OK, knowledgeable programmer-types, please be gentle... I'm having trouble getting a very simple, one-view
I embedded a opentype font with @font-face. Works fine, but the bbox or descent
I certainly hope someone can help ease my frustration. I am trying to find
I have a certain problem with my Makefile. With this command, I can compile
I know you can apply a function/formula by clicking and dragging the bottom right,
This function keeps giving me problem I cannot seem to find the right combination
i'm facing a problem right now, i need to count the number of time
I'm hoping to get pointed in the right direction here. The problem I'm having

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.