I have some problem. I use ProperyGrid to modify object properies (I have mdi window control. And for selected window I set class A to PropertyGrid.Item in dynamic). In class A I have Prop1 and List1 of suitable values for Prop1. Prop1 is a selected value from List1. How can I display this property in ProperyGrd?
Thanks.
6 Answers, 1 is accepted
You can try handling AutoGeneratingPropertyDefinition event of RadPropertyGrid and create new LookupPropertyDefinition, set its required properties and assign it to the e.PropertyDefinition.
The exact implementation depends entirely on your exact settings and requirements, but it could be something similar to:
private void OnAutoGeneratingPropertyDefinition(object sender, AutoGeneratingPropertyDefinitionEventArgs e)
{
var lookup = new LookupPropertyDefinition();
lookup.ItemsSource = list1;
.........
e.PropertyDefinition = lookup;
}
Kind regards,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Thanks for the answer. But I think I can't use this solution, because objects are very diffrent. I use Prism and module pattern in my application. I don't want to write code in OnAutoGeneratingPropertyDefinition method, because in this context application don't know about objects.
It will be good to use DataAnnotation to resolve this problem.But I think it's impossible. Am I right?
I found solution. In every mdi window I write in XAML list of PropertyDefinitions (dependency property). And when I handle that the window is selected I add collection of propertyDefinitions to the PropertyGrid.
Thanks.
Generally, during AutoGeneratingPropertyDefinition event, you will most probably have the information for the object and its properties.
Nevertheless, I am happy to see that you found the most appropriate solution for your case.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

///
<summary>
/// Очищает окно свойство
/// </summary>
private void ClearPropertyGrid()
{
if(PropertyGrid == null) return;
PropertyGrid.PropertyDefinitions.Clear();
PropertyGrid.Item =
null;
}
#endregion
#region
Public Methods
public void SetActiveItem(IElementWithPropertyDefinitions element)
{
if(Equals(element, _activeElement) || PropertyGrid == null) return;
_activeElement = element;
//Удалить свойства текущего окна
ClearPropertyGrid();
//Добавить свойства нового окна
foreach (var propertyDefinition in element.PropertyGridDefinitions)
{
PropertyGrid.PropertyDefinitions.Add(propertyDefinition);
}
PropertyGrid.Item = control.DataContext;
}
I have only 1 property in test but I see a time delay (use dotTrace Perfomance 4.0):
22.78% - Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object,NotifyCollectionChangedEventArgs)
14.15% - Telerik.Windows.Controls.RadPropertyGrid.OnItemPropertyChanged(DependencyObject, DependencyPropertyChangedEventArgs)
You can download our latest internal build where PropertyDefinitions collection is ObservableItemCollection<PropertyDefinition>. Thus you will be able to call SuspendNotifications() and ResumeNotifications() methods on updating the collection.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
