locked
Refresh Page Controls Binding In View Model RRS feed

  • Question

  • Hi All,

    Am Developing Win 8.1 Store App.

    In mY App i have an requirement that allows user to take picture and show in grid or list view in the screen immediately.

    Am using Galasoft MVVM Light dll.

    how do i achieve the same in my viewmodel with refreshing controls.

    if i do the binding in xaml.cs file it is refreshing but if i do the same in Viewmodel it is not.

    Any suggestion would be of great help 

    Thanks

    Arjun


    Arjun

    Tuesday, April 15, 2014 9:14 AM

All replies

  • The view model should implement the INotifyPropertyChanged interface and raise its PropertyChanged event when a value of a bound source property changes: http://msdn.microsoft.com/en-us/library/windows/apps/system.componentmodel.inotifypropertychanged

    You typically raise this event in the setter of the bound source property:

    public string CustomerName
            {
                get
                {
                    return this.customerNameValue;
                }
    
                set
                {
                    this.customerNameValue = value;
                    NotifyPropertyChanged();
                }
            }
    

    If you are using MVVM Light, your view model class can inherit from the ViewModelBase class and call its RaisePropertyChanged method, passing in the name of the source property:

    public string CustomerName
            {
                get
                {
                    return this.customerNameValue;
                }
    
                set
                {
                    this.customerNameValue = value;
                    RaisePropertyChanged("CustomerName");
                }
            }
    

    Please share your code for further help.

    Tuesday, April 15, 2014 9:28 AM
  • Hi Arjun are you binding to an Observable collection from your list view? Are you leveraging the RaisePropertyChanged events?

    Tuesday, April 15, 2014 9:31 AM
  •  Hi Dave,

    Thanks For your Reply,

    I Used Raise property changed event,but still its of no use.

    My Code is Hitting Raise Property Changed Event but is is not reflecting in my View.

    Any Suggestion would be of great help.

    thanks

    arjun


    Arjun

    Tuesday, April 15, 2014 6:35 PM