Click here to Skip to main content
13,548,904 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
I'm using the WPF Extended Toolkit PropertyGrid (v1.7), and I'm trying to setup a custom editor to display a dialog box when the user clicks a button. My problem is that I can't get the property grid to display the editor panel at all.

The property in question is properly adorned with the following attributes (and the property itself does show up in the propertygrid):
[Editor(typeof(CDSceneSelectorEditor), typeof(DialogPropertyValueEditor))]
[DisplayName("Base Scene")]
public Image BaseSceneImage { get; set; }

I tried doing it as follows, but it wouldn't display the editor panel, and after some investigation in the debugger, I noticed that the template's VisualTree was null:
public class CDSceneSelectorEditor : DialogPropertyValueEditor
    public CDSceneSelectorEditor()

        string template = 
            @"<DataTemplate xmlns=''
//                          xmlns:pe='clr-namespace:System.Activities.Presentation.PropertyEditing;assembly=System.Activities.Presentation'>
                <DockPanel LastChildFill='True'>
                <pe:EditModeSwitchButton TargetEditMode='Dialog' Name='EditButton' 
                                         DockPanel.Dock='Right' Content='...' />
                <TextBlock Text='Picture' Margin='2,0,0,0' 

            using (var sr = new MemoryStream(Encoding.UTF8.GetBytes(template)))
                this.InlineEditorTemplate = (DataTemplate)(XamlReader.Load(sr));
        catch (Exception ex)
            if (ex != null) {}

So, I figured that the visual tree must be the issue, so I tried it this way, which gave me a VistalTree, but didn't change the result:
public class CDSceneSelectorEditor : DialogPropertyValueEditor
    public CDSceneSelectorEditor()
        var button = new FrameworkElementFactory(typeof(EditModeSwitchButton))
                         { Name = "EditButton"     };
        button.SetValue(DockPanel.DockProperty, Dock.Right);
        button.SetValue(EditModeSwitchButton.ContentProperty, " ... ");
        button.SetValue(TextBlock.MarginProperty, new Thickness(0,0,3,0));

        var image  = new FrameworkElementFactory(typeof(Image))
                         { Name = "ThumbnailImage" };

        var panel  = new FrameworkElementFactory(typeof(DockPanel));

        DataTemplate template = new DataTemplate();
        template.VisualTree = panel;
        this.InlineEditorTemplate = template;

I am out of ideas, and google has been no help at all.
Posted 15-Oct-12 7:43am
Updated 16-Oct-12 4:21am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180515.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100