Custom Editor Panel Not Showing Up

Oct 12, 2012 at 4:39 PM
Edited Oct 16, 2012 at 6:44 PM

I'm using the PropertyGrid control in the WPF Extended Toolkit (v1.70).

I'm trying to implement 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, like so, and the property name does, in fact, appear in the property grid:


[Editor(typeof(CDSceneSelectorEditor), typeof(DialogPropertyValueEditor))]
[DisplayName("Base Scene")]
public Image BaseSceneImage {get; set; }


I tried doing it this way, but it wouldn't display, 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=''

                <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) {}

I figured that the visual tree being null must be the issue, so I tried it like this, 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. Why isn't the editor panel being displayed in the propertygrid control?

EDIT =================

I tried adding a DataTemplate to the PropertyGrid Xaml, and it shows the panel just fine, but that's not the way I thought it was suppose to work.