Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
xamPropertyGrid with PropertyDescriptor
posted

Hi,

We are evaluating the xamPropertyGrid, and we are testing a special case that doesn´t appears inside the Infragistics Samples 16.1.

In our test case, we are using a ViewModel inheriting from CustomTypeDescriptor. In this View Model we have a List, and in the GetProperties method we are getting the properties of the list objects. This objects are coming with a PropertyDescriptor to modify the DisplayName, the Category depending of the object properties. 

We want to show only the list objects, we don´t want to show the collection item concentrator.

In our example, we have two controls:

  • button (to set a Value from outside the Property Grid.)
  • Property Grid.

The problem is that the property grid doesn´t refresh the data, if we update the data from  button´s event.

I attached a solution with the problem.

What are we doing wrong? Which is the correct way?

PropertyGrid.zip
Parents
No Data
Reply
  • 1935
    Verified Answer
    posted

    Hello David,

    Thank you for providing a sample!

    I have taken a look at the sample and the reason why the XamPropertyGrid does not refresh its data is that ListGenericViewModel view model class is not raising change notifications for the ParameterViewModel view model class. In other words, XamPropertyGrid is listening for property change notifications on ListGenericViewModel and in this case we need to raise change notifications for the ParameterViewModel.

    What you could do is to hook to the PropertyChanged event handler when adding the ParameterViewModels.

    That is a snippet code illustrating the notification for the ParameterViewModel:

           public ListGenericViewModel(string prefix)
            {
                ParameterViewModel pvm = new ParameterViewModel(prefix) { Value = prefix, Name = "First Name", Category = "Personal Data" };
                Properties.Add(pvm);
                pvm.PropertyChanged += Pvm_PropertyChanged;

                pvm = new ParameterViewModel("Garc�) { Value = "Garc�, Name = "Last Name", Category = "Personal Data" };
                Properties.Add(pvm);
                pvm.PropertyChanged += Pvm_PropertyChanged;
            }

            private void Pvm_PropertyChanged(object sender, PropertyChangedEventArgs e)
            {
                ParameterViewModel pvm = sender as ParameterViewModel;

                OnPropertyChanged(pvm.Name);
            }

    Please take a look at the modified version of the sample and let me know if you have any questions on this matter.

    PropertyGrid_Modified.zip
Children