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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:07:04+00:00 2026-05-17T21:07:04+00:00

I’ve set up a custom control in SL and I’m trying to get the

  • 0

I’ve set up a custom control in SL and I’m trying to get the default look of the control to behave properly. I feel (with the help of some smart folks on here) that I am getting pretty close to getting this, but I’m still not quite there yet.

When my control is first added to a panel in Blend, it shows up as I expect based on the template, and when I modify the dependency properties I’ve exposed, those work fine as well. The problem I’m having now is that when make a change through Blend and then “reset” that value using the options box, it resets the property under the Miscellaneous pane, but doesn’t actually change the control itself in the design view unless I build the project again.

Here’s the code I currently have:

    public enum SolidGlossTypes
    {
        Normal,
        Header,
        Footer,
        None
    }

    public SolidGlossTypes SolidGlossType
    {
        get
        {
            return (SolidGlossTypes)GetValue(SolidGlossTypeProperty);
        }
        set
        {
            SetValue(SolidGlossTypeProperty, value);
            switch (value)
            {
                case SolidGlossTypes.Header:
                    SolidGloss_Upper.Visibility = Visibility.Visible;
                    SolidGloss_Lower.Visibility = Visibility.Collapsed;
                    break;
                case SolidGlossTypes.Footer:
                    SolidGloss_Upper.Visibility = Visibility.Collapsed;
                    SolidGloss_Lower.Visibility = Visibility.Visible;
                    break;
                case SolidGlossTypes.None:
                    SolidGloss_Upper.Visibility = Visibility.Collapsed;
                    SolidGloss_Lower.Visibility = Visibility.Collapsed;
                    break;
                default:
                    SolidGloss_Upper.Visibility = Visibility.Visible;
                    SolidGloss_Lower.Visibility = Visibility.Visible;
                    break;
            }
        }
    }

    public static readonly DependencyProperty SolidGlossTypeProperty = DependencyProperty.Register("SolidGlossType", typeof(SolidGlossTypes), typeof(SolidGloss), new PropertyMetadata(SolidGlossTypes.Normal));

I’ve tried tinkering with a property changed callback but haven’t had any success getting it to work.

Also, is it possible to set the default values of a dependency property to a style within generic.xaml and then bind to that from the template?

Thanks in advance,

E

  • 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-17T21:07:05+00:00Added an answer on May 17, 2026 at 9:07 pm

    The problem is you’ve placed additional code in your Setter. When using Dependency properties the setter is not always called, for example when some other external code calls SetValue passing in SolidGlossTypeProperty and a new value, your setter is not called.

    You sould use the property callback method to perform additional operations instead.

    Edit

    For example:-

    public SolidGlossTypes SolidGlossType 
    { 
        get 
        { 
            return (SolidGlossTypes)GetValue(SolidGlossTypeProperty); 
        } 
        set 
        { 
            SetValue(SolidGlossTypeProperty, value);  
        } 
    } 
    
    public static readonly DependencyProperty SolidGlossTypeProperty = DependencyProperty.Register(
        "SolidGlossType",
        typeof(SolidGlossTypes),
        typeof(SolidGloss),
        new PropertyMetadata(SolidGlossTypes.Normal, OnSolidGlossTypePropertyChanged)); 
    
    
    private static void OnSolidGlossTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
            SolidGloss source = d as SolidGloss;
            SolidGlossTypes value = (SolidGlossTypes)e.NewValue
    
            switch (value) 
            { 
                case SolidGlossTypes.Header: 
                    source.SolidGloss_Upper.Visibility = Visibility.Visible; 
                    source.SolidGloss_Lower.Visibility = Visibility.Collapsed; 
                    break; 
                case SolidGlossTypes.Footer: 
                    source.SolidGloss_Upper.Visibility = Visibility.Collapsed; 
                    source.SolidGloss_Lower.Visibility = Visibility.Visible; 
                    break; 
                case SolidGlossTypes.None: 
                    source.SolidGloss_Upper.Visibility = Visibility.Collapsed; 
                    source.SolidGloss_Lower.Visibility = Visibility.Collapsed; 
                    break; 
                default: 
                    source.SolidGloss_Upper.Visibility = Visibility.Visible; 
                    source.SolidGloss_Lower.Visibility = Visibility.Visible; 
                    break; 
            }
    }
    

    In this arrangement whenever the value of SolidGlossTypeProperty is changed by whatever means (the setter in your code, by animation or by other direct calls to SetValue) the callback property changed method will always be called.

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

Sidebar

Related Questions

No related questions found

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.