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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:59:00+00:00 2026-05-17T22:59:00+00:00

I have setup binding as follows XAML <TextBlock Text={Binding Path=Color, Converter={StaticResource ColorToStringConverter}} /> C#:

  • 0

I have setup binding as follows

XAML

 <TextBlock Text="{Binding Path=Color, Converter={StaticResource ColorToStringConverter}}" />

C#: Showing what Color is

public System.Windows.Media.Color Color
{
    get
    {
        var color = new HSLColor { Hue = this.Hue, Saturation = this.Saturation, Luminosity = this.Luminosity };
        string strColor = color.ToRGBString();
        return new System.Windows.Media.Color { 
            R = byte.Parse(strColor.Substring(0, 2), System.Globalization.NumberStyles.HexNumber),
            G = byte.Parse(strColor.Substring(2, 2), System.Globalization.NumberStyles.HexNumber),
            B = byte.Parse(strColor.Substring(4, 2), System.Globalization.NumberStyles.HexNumber)
        };
    }
    set { SetValue(ColorProperty, value); }
}

Converter

public class ColorToStringConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        Color color = (Color)value;
        return color.ToString();
    }
}

But my converter is getting value like

value = "{Name=0, ARGB=(0, 0, 0, 0)}"

I’d expect it to be a System.Windows.Media.Color why am I getting this?

Basically, I have 3 Silders for HSL values bound to DependencyProperties, each have a PropertyChangedCallback attached to them

new PropertyChangedCallback(HSLValuePropertyChanged)

It looks like

protected void HSLValueChanged()
{
    if (PropertyChanged != null)
        PropertyChanged(this, new PropertyChangedEventArgs("Color"));
}

Basically its purpose is to update controls bound to the dependency property Color. The idea is that get should run for property Color which creates a new color from HSL properties. The problem it seems is that the get does not run even when I change HSL values.

UPDATE

So I tried to return just value in the case of an exception, I got nothing in the textbox, so i did value.toString() got Color [Empty] all the time. What did I do wrong?

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
    try
    {
        Color color = (Color)value;
        return color.ToString();
    } catch (Exception) {
        return value.ToString();
    }
}
  • 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-17T22:59:00+00:00Added an answer on May 17, 2026 at 10:59 pm

    You seem to be using the ColorDependencyProperty.
    If so, I think the binding may never actually go trough the accessors (get/set) …

    You should set the new color (in the dependencyProperty via the setvalue method) on each of your H/S/L properties change call back…

    I hope i am clear 🙂

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

Sidebar

Related Questions

I have setup a property and implement INotifyPropertyChanged like so... public event PropertyChangedEventHandler PropertyChanged;
I have an custom binding defined as follows: <customBinding> <binding name=binaryHttpBinding> <binaryMessageEncoding /> <httpTransport
I have the following Data Trigger set-up on a Control Template <DataTrigger Binding={Binding Path=IsDragged}
I have a DataTrigger setup like so: <UserControl.Resources> <Style x:Key=resultTypeStyle> <Style.Triggers> <DataTrigger Binding={Binding Result,
I have a DataGrid that is setup like this: <DataGrid AutoGenerateColumns=True GridLinesVisibility=Horizontal IsReadOnly=True ItemsSource={Binding
I have setup web dav on windows server 2008. It seems to work fine
At the moment I have setup a custom ok cancel dialog with a drop
I've created some MbUnit Test Fixtures that have SetUp methods marked with the SetUp
I am trying to implement performance testing on ActiveMQ, so have setup a basic
Setup Have you ever had the experience of going into a piece of code

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.