locked
Property value change and notification timing -MVVM RRS feed

  • Question

  • I ahve a form which takes values from a user when a button is clicked. It is done via MVVM where viewmodel has properties databound to UI items on form. When user enters the value  and clicks on button it does not get the entered value so display default values. And after some seconds I see in set for proeprty OnPropertychanged is called and it gets the new value. For one item it does not get newly entered value for a long time.

    Sunday, May 15, 2011 10:24 PM

Answers

  • Binded property to the textbox should be in two way mode and raise property should be triggered within property

    e.g.

    private string selectedText;
    
    public string SelectedText
            {
                get
                {
                    return this.selectedText;
                }
    
                set
                {
                    if (this.selectedText != value)
                    {
                        this.selectedText = value;
                        RaisePropertyChanged("SelectedText");
                    }
                }
            }


     

    Here RaisePropertyChanged is the implemented event of INotifyPropertyChanged; if this is proper, its gonna work

    Sunday, May 15, 2011 11:02 PM
  • Hi,

    (sender as TextBox).GetBindingBLOCKED EXPRESSION;

    Event if you have implement INotifyPropertyChanged Interface TextBox control update value when lost focus.

    Because Silverlight team does not implement OnPropertyChanges for us so that

    How to solve?

    1. (sender as TextBox).GetBindingBLOCKED EXPRESSION;

    2. Create custom behavior

    3. Borrow Prism assemblies

    Monday, May 16, 2011 8:10 AM

All replies

  • Binded property to the textbox should be in two way mode and raise property should be triggered within property

    e.g.

    private string selectedText;
    
    public string SelectedText
            {
                get
                {
                    return this.selectedText;
                }
    
                set
                {
                    if (this.selectedText != value)
                    {
                        this.selectedText = value;
                        RaisePropertyChanged("SelectedText");
                    }
                }
            }


     

    Here RaisePropertyChanged is the implemented event of INotifyPropertyChanged; if this is proper, its gonna work

    Sunday, May 15, 2011 11:02 PM
  • Hi,

    (sender as TextBox).GetBindingBLOCKED EXPRESSION;

    Event if you have implement INotifyPropertyChanged Interface TextBox control update value when lost focus.

    Because Silverlight team does not implement OnPropertyChanges for us so that

    How to solve?

    1. (sender as TextBox).GetBindingBLOCKED EXPRESSION;

    2. Create custom behavior

    3. Borrow Prism assemblies

    Monday, May 16, 2011 8:10 AM