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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:31:11+00:00 2026-05-22T15:31:11+00:00

In my usercontrol.xaml.cs. I have this dependency proprerty as bleow. public static readonly DependencyProperty

  • 0

In my usercontrol.xaml.cs. I have this dependency proprerty as bleow.

public static readonly DependencyProperty MessageKeyProperty =
                 DependencyProperty.Register("MessageKey", typeof(String),
                 typeof(UC_MessageEntry),
                     new FrameworkPropertyMetadata(null,
                         new PropertyChangedCallback(MessageKeyPropertyChangedCallback)));


        private static void MessageKeyPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is UC_MessageEntry)
            {
                UC_MessageEntryucMessageEntryAccessDenied = (UC_MessageEntry)d;
                if (e.NewValue != null)
                {
                    ResourceBundle resourceBundle = App.ResourceBundle;
                    if (e.NewValue.ToString().Equals("enable"))
                    {
                        ucMessageEntryAccessDenied.txtAceessDeniedMsg.Text = "";
                        return;
                    }

                    String actualMessage = resourceBundle.GetString("Resources", e.NewValue.ToString());
                    if (actualMessage == null)
                    {
                        ucMessageEntryAccessDenied.txtAceessDeniedMsg.Text = resourceBundle.GetString("Resources", "ContractSetup.ExchangeAccessDeniedMessage.OTHERS");
                    }
                    else
                    {
                        ucMessageEntryAccessDenied.txtAceessDeniedMsg.Text = actualMessage;
                    }

                }
                else
                {
                    ucMessageEntryAccessDenied.txtAceessDeniedMsg = null;
                }
            }
        }


        public String MessageKey
        {
            get
            {
                return (String)this.GetValue(MessageKeyProperty);  
            }
            set
            {
                this.SetValue(MessageKeyProperty,value);
            }
        }

In mainwindow.xaml , i bind this MessageKey as below.

  <view_MessageEntry:UC_MessageEntry   
                                x:Uid="local:UC_MessageEntry_1" x:Name="UC_OrderEntry"  MessageKey="{Binding MsgAccessDenied}"
                                Style="{DynamicResource contentControlStyle}" SnapsToDevicePixels="True" Margin="0" />

And Behind MessageViewModle.cs,

private static readonly PropertyChangedEventArgs MsgAccessDeniedPropertyChangedEventArgs
    = new PropertyChangedEventArgs("MsgAccessDenied");

    private string _msgAccessDenied;
    public string MsgAccessDenied
    { 
       get
       {
           if (_selectedExchange != null)
           {
               return _msgAccessDenied;
           }
           else
           {
               return "enable";
           }
       }
        set
        {
            _msgAccessDenied = value;
            this.RaisePropertyChanged(this, MsgAccessDeniedPropertyChangedEventArgs);
        }

    }


public void FireMsg()
{
  this.MsgAccessDenied="value";
}

When the combo box selection is changed, I called FireMsg() and it will update the MessageKeyPropertyChangedCallback function in usercontrol.xaml.cs. It’s working fine. But If I call this FireMsg() from Other ViewModels, value of _msgAccessDenied is updated. But MessageKeyPropertyChangedCallback function is not firing. Any solution for this issue? Thanks.

  • 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-22T15:31:12+00:00Added an answer on May 22, 2026 at 3:31 pm

    Your code looks generally sound. But if your dependency property change callback is not being called, it is almost certainly because the value of the dependency property isn’t changing. And if the dependency property is bound to a source, then it is probably because the source isn’t changing.

    From my quick review of the code, the only way that I can see that happening is:

    • the value of MsgAccessDenied is set
    • this causes the field _msgAccessDenied to be set
    • the RaisePropertyChanged method is called to trigger PropertyChanged
    • the dependency subsystem does its thing which forces a get of MsgAccessDenied
    • the MsgAccessDenied getter is called
    • the getter checks _selectedExchange and it is null
    • the getter returns the value "enable" instead of the new value of _msgAccessDenied
    • the previous value was also "enable"
    • the dependency subsystem says, OK, no change
    • the property change callback is not called

    In summary, _selectedExchange can hide value changes in _msgAccessDenied, thereby preventing the upstream change callback from firing.

    This is just a theory.

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

Sidebar

Related Questions

I have this simple UserControl : <UserControl x:Class=WPFTreeViewEditing.UserControl1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 mc:Ignorable=d d:DesignHeight=300
Before I start, I have this code inside of a Custom Usercontrol: private DependencyProperty
I have a usercontrol like this: <UserControl x:Class=MySample.customtextbox xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 mc:Ignorable=d d:DesignHeight=20
I have custom control with following: <TextBox Grid.Column=3 Text={TemplateBinding SampleValue} /> public static readonly
I have a basic WinRT XAML UserControl with a single dependency property as implemented
I have a UserControl that I've added a Dependency Property to: public partial class
I have a class like this: public class Stretcher : Panel { public static
I have this User Control XAML: <Window x:Class=MyProj.Dialog xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:shell=http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell mc:Ignorable=d>
I have the following XAML: <UserControl x:Class=EMS.Controls.Dictionary.TOCControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:vm=clr-namespace:EMS.Controls.Dictionary.Models xmlns:diagnostics=clr-namespace:System.Diagnostics;assembly=WindowsBase x:Name=root > <TreeView
I have created a UserControl as follows: <UserControl x:Class=MySample.MyControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:local=using:MySample xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006

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.