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

PropertyGrid overwriting DataContext of custom editor control

Aug 30, 2016 at 10:32 PM
I have a custom Property Grid editor, and the data context of the control is being overwritten, which causes issues with viewmodels, etc.

Example:
public class MyCustomEditor : ITypeEditor
{
    public FrameworkElement ResolveEditor(PropertyItem propertyItem)
    {
        var button = new Button();
        button.DataContext = "example";
        button.DataContextChanged += (sender, args) => {Console.WriteLine("Data context changed!"); };
        return button;
    }
}
The event will trigger after the Property Grid loads the editor, overwriting the initial data context.

Is this intentional behaviour?
Developer
Sep 6, 2016 at 3:19 PM