0

I have a UserControl that add a DependencyProperty for it .

    public const string TextValuePropertyName = "TextValue";
      public string TextValue
    {
        get
        {
            return (string)GetValue(TextValueProperty);
        }
        set
        {
            SetValue(TextValueProperty, value);
        }
    }
     public static readonly DependencyProperty TextValueProperty = DependencyProperty.Register(
        TextValuePropertyName,
        typeof(string),
        typeof(FormatUserControl),
        new UIPropertyMetadata());

and use it in another Usercontrol

       <local:FormatUserControl   TextValue="{Binding Subject,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  />

When i use this don't set value for this property when i change Subject value?

1
  • 2
    How do you know? You haven't registered a PropertyChangedCallback with the dependency property metadata. Note that WPF does usually not call the setter of the property wrapper, as explained here. Commented Sep 18, 2013 at 8:30

1 Answer 1

1

Your FormatUserControl is the class and you should register the property for it not for the NumberFormatUserControl like this (I am not aware what is the relationship between the two user controls):

public static readonly DependencyProperty TextValueProperty = DependencyProperty.Register(
    TextValuePropertyName,
    typeof(string),
    typeof(FormatUserControl),
    new UIPropertyMetadata());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.