New to Telerik UI for WPF? Download free 30-day trial

Propertygrid's collection editor name property not updating

Environment

Product Version 2018.2.620
Product RadPropertyGrid for WPF

Description

How to data bind a property from the model of the collection shown in the collection editor to the left side names of the editor opened when a collection property is selected.

Solution

  1. Define a DataTemplate containing a TextBlock bound to a property from the model of the items in the collection.

        <Window.Resources> 
            <DataTemplate x:Key="CollectionEditorTemplate"> 
                <TextBlock Text="{Binding Name}" /> 
            </DataTemplate> 
        </Window.Resources> 
    
  2. Subscribe to the FieldLoaded event of RadPropertyGrid and set the ItemTemplate of the loaded editor. Do this only if the editor is an element of type CollectionEditorPicker.

        private void radPropertyGrid_FieldLoaded(object sender, FieldEventArgs e) 
        { 
            var collectionEditorPicker = e.Field.Content as CollectionEditorPicker; 
            if (collectionEditorPicker != null) 
            { 
                Dispatcher.BeginInvoke(new Action(() => { 
                    var editor = collectionEditorPicker.CollectionEditor; 
                    editor.ItemTemplate = (DataTemplate)this.Resources["CollectionEditorTemplate"]; 
                })); 
            }            
        } 
    
In this article