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:
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?
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.
Hello Martin,
Thank you for you answer. It works fine, but the square that indicates that the value is not the default don´t change and I cannot reset the value thrown the context menu.
Thank you in advance.