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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:38:45+00:00 2026-05-20T01:38:45+00:00

This is a bit of a wierd problem. (.NET 3.5sp1) I have a UserControl

  • 0

This is a bit of a wierd problem. (.NET 3.5sp1)

I have a UserControl containing three ToggleButtons, each with IsChecked bound to different dependency properties on the UserControl itself. Two of these default to true, one defaults to false.

On startup of the application, the UserControl itself (and thus its contents) is disabled. When it gets enabled later on, all three buttons appear un-pressed; however the code properties are still in the correct state.

If the buttons are clicked then the properties will toggle properly and the UI (for that button only) will update to reflect the correct state (ie. clicking on a button which appears un-pressed but has a true bound value will show no visible change the first time, but updates the bound value to false). Pressing a “glitched” button for the second time will behave normally (if it toggles on, the button will press in as expected).

If the UserControl is not disabled on startup, then the buttons will appear correctly (according to the state of the properties).

Unfortunately the UserControl is supposed to be disabled on startup, so I can’t really start up with it enabled; I’m hoping for an alternate solution. Any ideas?

(I’ve tried making the properties default to false and then setting them to true in the user control’s Load event. Doesn’t make any difference.)

  • 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-20T01:38:45+00:00Added an answer on May 20, 2026 at 1:38 am

    The same weird problem happens in .NET 4.0 as well. I noticed that the problem only occurs if you set IsEnabled through code and not if you bind it, so if you can change your code to that instead I believe your problem will be solved.

    Otherwise, I believe a workaround is necessary and here is one way to do it. Reset the DataContext for the UserControl the first time IsEnabled is set to True.

    public UserControl1()
    {
        InitializeComponent();
    
        DependencyPropertyDescriptor descriptor =
            DependencyPropertyDescriptor.FromProperty(UserControl1.IsEnabledProperty, 
                                                      typeof(UserControl1));
        EventHandler isEnabledChanged = null;
        isEnabledChanged = new EventHandler(delegate
        {
            if (IsEnabled == true)
            {
                descriptor.RemoveValueChanged(this, isEnabledChanged);
                var dataContext = this.DataContext;
                this.DataContext = null;
                this.DataContext = dataContext;
            }
        });
        descriptor.AddValueChanged(this, isEnabledChanged);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a little bit of weird problem here. Say I have a C++
This is a bit weird, but I have no idea where the problem is.
So I have this bit of code for x in range(x1,x2): for y in
I have this bit of code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
i'm having a bit of a weird problem. I programmed a asp.net mvc app
I have problem passing a variable from a main page containing a user control
Strange Question i guess but i have this bit of code in my page...
I have a wierd problem that i need to work out how to resolve,
Greetings folks. I have this weird problem. In the project I'm working on now,
I have a bit of a weird problem here! I am trying to write

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.