Simple drop down editor?

2 posts, 0 answers
  1. Karl
    Karl avatar
    37 posts
    Member since:
    Dec 2013

    Posted 18 Aug 2016 Link to this post

    How can I make this work with the property grid?  I am using a property grid with automatically generated properties and on edit I want SelectedIndex1 and SelectedIndex2 to display a list of my available indexes for the user to choose from.

    public class MyIndexSelector
        private readonly List<int> m_someList = new List<int> () {1, 2, 3};
        [Browsable (false)]
        public List<int> AvailableIndexes { get { return m_someList; } }
        //??[Telerik.Windows.Controls.Data.PropertyGrid.Editor (typeof (IndexEditorControl), Telerik.Windows.Controls.Data.PropertyGrid.EditorStyle.DropDown)]
        public int SelectedIndex1 { get; set; }
        //??[Telerik.Windows.Controls.Data.PropertyGrid.Editor (typeof (IndexEditorControl), Telerik.Windows.Controls.Data.PropertyGrid.EditorStyle.DropDown)]
        public int SelectedIndex2 { get; set; }


  2. Dilyan Traykov
    Dilyan Traykov avatar
    603 posts

    Posted 19 Aug 2016 Link to this post

    Hello Karl,

    The suggested approach in this scenario would be to create a custom DataTemplate and set that as the EditorTemplate for the PropertyDefinitions of interest in RadPropertyGrid's AutoGeneratingPropertyDefinition event:

    private void RadPropertyGrid_AutoGeneratingPropertyDefinition(object sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
        if (e.PropertyDefinition.SourceProperty.Name == "Country")
            e.PropertyDefinition.EditorTemplate = (DataTemplate)Application.Current.Resources["ComboBoxTemplate"];

        <DataTemplate x:Key="ComboBoxTemplate">
            <telerik:RadComboBox ItemsSource="{Binding Countries}" SelectedValue="{Binding Country}" />

    I'm attaching a sample project to better demonstrate this. Please have a look at it and let me know whether such an approach would work for you.

    Dilyan Traykov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top