1

I have implemented the binding using the answer posted here: WPF Binding to local variable and this: https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx

It looks like this:

public partial class AddCard: DXWindow, INotifyPropertyChanged
{
   public event PropertyChangedEventHandler PropertyChanged;
   private int _CardNumber;

   public int CardNumber
   { 
       get { return _CardNumber; }
       set
       {
           if (value != _CardNumber)
           {
              _CardNumber = value;
              OnPropertyChanged("CardNumber");
           }
       }
   }

   private void OnPropertyChanged(string p)
   {
       if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(p));
   }
}

in xaml (I'm using DevExpress components):

    <dx:DXWindow
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
    .../>

<dxe:TextEdit Text="{Binding Path=CardNumber}"/>

The problem: When updating the CardNumber value in code - it updates the text box on the window, BUT updating the textbox in the window - doesn't update the property of CardNumber in code.

What am I missing?

1 Answer 1

2

By default updates only propagate through when the control loses focus. I suspect you want them to update immediately, in which case add 'UpdateSourceTrigger=PropertyChanged' to your binding.

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.