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

The Archive Base Latest Questions

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

I have a custom ClockFace UserControl which has properties to allow colors, font and

  • 0

I have a custom ClockFace UserControl which has properties to allow colors, font and hands (as a Path objects) to be changed. This is used in custom TimePicker and Clock UserControls. In these parent controls, the ClockFace properties can be set on the ClockFace object in xaml just fine.
What I’m trying to do is expose these ClockFace properties so that they can be set on these two parent controls (eg. the Clock and TimePicker objects). I thought that making them Attached properties would do the trick, so I tried with one of the colour properties.

public static readonly DependencyProperty HourTicksBrushProperty = DependencyProperty.RegisterAttached("HourTicksBrush", typeof(Brush), typeof(ClockFace), new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender));
public static void SetHourTicksBrush(DependencyObject element, Brush value)
{
    element.SetValue(HourTicksBrushProperty, value);
}
public static Brush GetHourTicksBrush(DependencyObject element)
{
    return (Brush)element.GetValue(HourTicksBrushProperty);
}

I can use this attached property in the xaml where the Clock is with: (Controls is the xml namespace)

<Controls:Clock Controls:ClockFace.HourTicksBrush="Aqua" />

It compiles just fine, but although the default value (Brushes.Black) from the attached HourTicksBrushProperty shows, the value set on the parent Clock control (Aqua) never fire the above methods or change the colour. Am I missing something?

To be clear, I would like to be able to use the above xaml on a parent control to set the HourTicksBrush property of a child ClockFace control.

Any help would be much appreciated.

  • 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:09:54+00:00Added an answer on May 17, 2026 at 10:09 pm

    Those “get” and “set” methods in your attached property class are actually just convenience methods for your own codebehind. The XAML parser ignores these, calling element.SetValue itself. If you want to respond to a setter, you have to provide a property changed handler to the FrameworkPropertyMetadata

    public static readonly DependencyProperty HourTicksBrushProperty = DependencyProperty.RegisterAttached(
        "HourTicksBrush", 
        typeof(Brush), 
        typeof(ClockFace), 
        new FrameworkPropertyMetadata(
            Brushes.Black, 
            FrameworkPropertyMetadataOptions.AffectsRender,
            HourTicksBrushChanged));
    
    public static void SetHourTicksBrush(DependencyObject element, Brush value)
    {
        element.SetValue(HourTicksBrushProperty, value); //not always called
    }
    public static Brush GetHourTicksBrush(DependencyObject element)
    {
        return (Brush)element.GetValue(HourTicksBrushProperty); //not always called
    }
    private static void HourTicksBrushChanged(DependencyObject sender, somethingsomethingArgs args){
        // do stuff with sender and args.NewValue here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom-made wizard system which so far has been quite suitable. For most
I have custom Question objects which I render into html form elements. I want
I have custom event that has several different subscribers who will all use the
I have custom components which must adjust their text content based on space constraints.
I have custom exceptions in my django project that look like this: class CustomFooError(Exception):
I have custom cell which contains number of rows in it.i want to write
I have custom js/jquery code which is running fine on all browsers including IE9
I have custom assembly that is loaded on runtime. at this point i have
I have custom javascript code for tabs which works fine, but Im trying to
I have custom CSS for checkbox control into my web form, which is linked

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.