RadPropertyGrid problem with EditorTemplate in Single EditMode

2 posts, 0 answers
  1. Sergei
    Sergei avatar
    7 posts
    Member since:
    Jun 2015

    Posted 14 Oct Link to this post

    In my project I use RadPropertyGrid. I can't set custom editors in xaml because I don't know properties of PropertyGrid.Item in design mode.
    I defined PropertyDefinition and set EditorTemplate in run time.

    <DataTemplate x:Name="CustomComboBox">
       <ComboBox telerik:AutoBindBehavior.UpdateBindingOnElementLoaded="SelectedValue" SelectionMode="Single" Loaded="ComboBox_Loaded"/>
    </DataTemplate>

    I have dynamically set some properties of Editors in Loaded() event (for example ItemsSource for ComboBox).

    I use PropertyGridField.AutoGeneratedPath to define witch editor is loading.

    private void ComboBox_Loaded(object sender, RoutedEventArgs e)
    {
       string propertyName = ((PropertyDefinition)((PropertyGridField)((ComboBox)sender).Parent).DataContext).AutoGeneratedPath;
       //creating itemsList...
       ((ComboBox)sender).ItemsSource = itemsList;
       ((ComboBox)sender).DisplayMemberPath = "DisplayName";
       ((ComboBox)sender).SelectedValuePath = "Code";
    }

    In EditMode="Default" it works fine.

    If I set EditMode to Single this solution will not work.

    In Loaded() event sender.Parent = null.

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 19 Oct Link to this post

    Hello Sergei,

    Here is an alternative approach for getting the bound property which will work in both edit modes:

    var comboBox = sender as ComboBox;
    var pd = comboBox.ParentOfType<PropertyGridField>().DataContext as PropertyDefinition;
    var propertyName = pd.AutoGeneratedPath;

    Please let me know if this would work for you. If that is not the case, please provide more details regarding you exact requirements and I will gladly guide you further in finding a solution for your particular scenario.

    Regards,
    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.
  3. DevCraft banner
Back to Top