This project has moved. For the latest updates, please go here.

Create an editor for property grid in one project and add refrence to another project

Sep 27, 2012 at 3:50 PM
Edited Sep 27, 2012 at 3:53 PM

Hey,

I created a very simple editor for my property grid, which create a simple button.

When I had the editor file to the project everything works GREAT.

When I referenced it form another project , everything compiles, but the editor doesn't appear. (i get the default editor for the property).

When I checked with a break point inside the ResolveEditor method I can see that the break point is not reached.

Can someone please help me with this problem?

here is my editor code:

 

using Xceed.Wpf.Toolkit.PropertyGrid;
using Xceed.Wpf.Toolkit.PropertyGrid.Editors;

 public class AssignmentButton :ITypeEditor
    {
        Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem property;

        public FrameworkElement ResolveEditor(PropertyItem propertyItem)
        {
            property = propertyItem;
            Button button = new Button();
            button.Content = "Collection";
        
            return button;
        }
    }

 

 

Here is the object I use:

 

  public class Host
    {

        [Browsable(false)]
        public int ID { get; set; }
        public string IP { get; set; }
        public string Description { get; set; }
        [Editor(typeof(AssignmentButton), typeof(AssignmentButton))]
        public List<Importer> HostedImporters { get; set; }
        [Editor(typeof(AssignmentButton), typeof(AssignmentButton))]
        public List<Distributor> HostedDistributors { get; set; }
        [Editor(typeof(AssignmentButton), typeof(AssignmentButton))]
        public List<DBLoader> HostedDBLoaders { get; set; }

    }

 

Sep 28, 2012 at 1:30 PM

Be sure that:

All your targeted properties are NOT marked with the "ExpandableObjectAttribute" attribute, and that they are read/write (get/set)

Check if the problem is still present when you try with properties using native types (ex. int ) instead of List<T>

Sep 30, 2012 at 7:15 AM

Thank you for your quick response,

All the targeted properties are not marked with the "ExpandableObjectAttribute" attribute.

I tried to mark it on an integer property but the problem still remains.

Can anybody try it and tell me if they can make it work? (referenced an editor from another project)

Because I got the feeling that its a bug.

Oct 1, 2012 at 2:25 PM

This issue has been created based on this thread:

http://wpftoolkit.codeplex.com/workitem/18734

Oct 2, 2012 at 10:03 AM
Edited Oct 2, 2012 at 10:03 AM

Does it means that it's a bug ? or should I try something else?

Oct 2, 2012 at 5:01 PM

Seems like a bug. I've created an issue to ease our tracking of this problem.

You are lucky, this one as been selected to be addressed for the next release. (this month)

Developer
Oct 5, 2012 at 1:11 PM

Please have a look at the issue relative to this discussion http://wpftoolkit.codeplex.com/workitem/18734. Based on the code you provided above, a zip file have been attached with an Editor from a project A which is referenced from project B : Everything work as expected. Can you provide more info if the problem still occurs ?

Jan 24, 2015 at 1:24 PM
I am having a similar problem.

eranop1 did you ever find out what was wrong?
Jan 24, 2015 at 3:24 PM
Edited Jan 24, 2015 at 3:25 PM
Ok Guys, I have found out why my editor was not being used and maybe this might help someone else who is also suffering from this problem.

In my case I had 3 assemblies:

Assembly A : a C# library assembly where I put my custom property grid Editors (e.g. TestEditor).
Assembly B : a C# library assembly where I put my business objects (e.g. MyClass) that are to be shown in the property grid.
Assembly C : a WPF application that displays a window containing a PropertyGrid control.

So far so good, everything compiles and runs. However, my TestEditor does not end up getting used (instead the default editor is shown). After digging around and looking at the code provided by BoucherS (which helped a huge amount - thanks). I found out what was going wrong. The reason the editor was not getting shown was because of a missing assembly reference.

Assembly B referenced Assembly A because it used the TestEditor in the Editor attribute on one of MyClass's properties.
Assembly C referenced Assembly B because it was showing a MyClass object in the property grid.
But, Assembly C was not referencing Assembly A and for some reason this meant that it could not use the editor.

So the fix was to make sure that the assembly with the property grid (in my case the WPF application) also has a reference to the assembly with the editors.

This is not easy to find when the code compiles and runs and so if there is anything that can be done to help flag this up earlier then that would be appreciated.

Thanks,
Ben
Apr 23, 2015 at 4:34 PM
Edited Apr 23, 2015 at 4:55 PM
Any updates on this? I would really like to see this bug fixed. For my use, I cannot make my WPF application point to the assembly where my viewable object and custom editors are implemented. Other things such as custom itemsources and other things work... it's just the editors which are not recognized properly.
Developer
Apr 24, 2015 at 3:31 PM
Hi,
It doesn't seems like a bug. Does the informations provided in this post or in this thread : http://wpftoolkit.codeplex.com/workitem/18734 helps ?

Can you provide a sample if you still have the problem ? From what I see, it looks like a missing assembly reference in your project.