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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:30:42+00:00 2026-05-16T17:30:42+00:00

I have two UserControls (uc1 and uc2) loading into a third UserControl (shell). Shell

  • 0

I have two UserControls (uc1 and uc2) loading into a third UserControl (shell). Shell has two properties, uc1 and uc2, of type UserControl1 and UserControl2, and each have a DependencyProperty registered to their own classes called IsDirty:

public static readonly DependencyProperty IsDirtyProperty = DependencyProperty.Register("IsDirty", typeof (bool), typeof (UserControl1));
public bool IsDirty
{
    get { return (bool) GetValue(IsDirtyProperty); }
    set { SetValue(IsDirtyProperty, value); }
}

(same code for UserControl2)

Shell has TextBlocks bound to the IsDirty properties:

<TextBlock Text="{Binding ElementName=shell, Path=Uc1.IsDirty}"/>
<TextBlock Text="{Binding ElementName=shell, Path=Uc2.IsDirty}"/>

When I change the values of IsDirty in uc1 and uc2, Shell never gets notified. What am I missing? UserControl is descendant of DependencyObject…

The same behavior occurs if I have regular properties notifying changes via INotifyPropertyChanged.

If I raise a routed event from uc1 and uc2, bubbling up to Shell, then I can catch the Dirty value and everything works, but I shouldn’t have to do that, should I?

Thanks

Edit: The answer is to raise property changed event on the Uc1 and Uc2 properties or make them DPs.

  • 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-16T17:30:43+00:00Added an answer on May 16, 2026 at 5:30 pm

    I tried reproducing your problem using a simple setup, and it works fine for me. I’m not sure though if this setup is correct enough to replicate your situation. Anyway, I’m posting it just in case. It might be helpful:

    XAML:

    <Window x:Class="WpfApplication2.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:WpfApplication2"
            x:Name="shell"
            Title="MainWindow" Height="350" Width="525">
        <StackPanel>
            <Button Click="Button_Click">Click</Button>
            <TextBlock Text="{Binding ElementName=shell, Path=Uc1.IsDirty}"/>
        </StackPanel>
    </Window>
    

    Code-Behind:

    namespace WpfApplication2
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            private MyUserControl uc1 = new MyUserControl();
            public MyUserControl Uc1
            {
                get { return this.uc1; }
            }
    
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                this.uc1.IsDirty = !this.uc1.IsDirty;
            }
    
    
        }
    
        public partial class MyUserControl : UserControl
        {
            public MyUserControl()
            {
            }
    
            public bool IsDirty
            {
                get { return (bool)GetValue(IsDirtyProperty); }
                set { SetValue(IsDirtyProperty, value); }
            }
    
            // Using a DependencyProperty as the backing store for IsDirty.  This enables animation, styling, binding, etc...
            public static readonly DependencyProperty IsDirtyProperty =
                DependencyProperty.Register("IsDirty", typeof(bool), typeof(UserControl), new UIPropertyMetadata(false));
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two user controls uc1 and uc2. uc1 as button and uc2 has
Say I have two usercontrols, UC1 and UC2. A user selects something in UC1,
ASP.NET MVC I have one page Index.aspx where I'm loading two usercontrols into divs.
I have two UserControls - UserControl1.ascx and UserControl2.ascx in PageDefault.aspx: How I can call
I have a custom ClockFace UserControl which has properties to allow colors, font and
I have two UserControls: public partial class MKSelectMonthUC : UserControl { public static readonly
Have two folders with approx. 150 java property files. In a shell script, how
I have two different Silverlight UserControls imported with MEF from two different xaps. The
I have two usercontrols. One is loaded statically another dynamically. In the aspx page
I have a form with two different UserControls - one that contains a Telerik

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.