public static void SetOptions(DependencyObject element, PropertyGridWindowOptions value)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            element.SetValue(OptionsProperty, value);
        }
        public static void SetOptions(DependencyObject element, PropertyGridWindowOptions value)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            element.SetValue(OptionsProperty, value);
        }
        protected virtual Window GetEditor(PropertyGridProperty property, object parameter)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            string resourceKey = string.Format("{0}", parameter);

            if (string.IsNullOrWhiteSpace(resourceKey))
            {
                var att = PropertyGridOptionsAttribute.FromProperty(property);
                if (att != null)
                {
                    resourceKey = att.EditorResourceKey;
                }

                if (string.IsNullOrWhiteSpace(resourceKey))
                {
                    resourceKey = property.DefaultEditorResourceKey;
                    if (string.IsNullOrWhiteSpace(resourceKey))
                    {
                        resourceKey = "ObjectEditorWindow";
                    }
                }
            }

            var editor = TryFindResource(resourceKey) as Window;

            if (editor != null)
            {
                editor.Owner = this.GetVisualSelfOrParent <Window>();
                if (editor.Owner != null)
                {
                    PropertyGridWindowOptions wo = PropertyGridWindowManager.GetOptions(editor);
                    if ((wo & PropertyGridWindowOptions.UseDefinedSize) == PropertyGridWindowOptions.UseDefinedSize)
                    {
                        if (double.IsNaN(editor.Left))
                        {
                            editor.Left = editor.Owner.Left + ChildEditorWindowOffset;
                        }

                        if (double.IsNaN(editor.Top))
                        {
                            editor.Top = editor.Owner.Top + ChildEditorWindowOffset;
                        }

                        if (double.IsNaN(editor.Width))
                        {
                            editor.Width = editor.Owner.Width;
                        }

                        if (double.IsNaN(editor.Height))
                        {
                            editor.Height = editor.Owner.Height;
                        }
                    }
                    else
                    {
                        editor.Left   = editor.Owner.Left + ChildEditorWindowOffset;
                        editor.Top    = editor.Owner.Top + ChildEditorWindowOffset;
                        editor.Width  = editor.Owner.Width;
                        editor.Height = editor.Owner.Height;
                    }
                }
                editor.DataContext = property;
                Selector selector = LogicalTreeHelper.FindLogicalNode(editor, "EditorSelector") as Selector;
                if (selector != null)
                {
                    selector.SelectedIndex = 0;
                }

                Grid grid = LogicalTreeHelper.FindLogicalNode(editor, "CollectionEditorListGrid") as Grid;
                if (grid != null && grid.ColumnDefinitions.Count > 2)
                {
                    if (property.IsCollection && CollectionEditorHasOnlyOneColumn(property))
                    {
                        grid.ColumnDefinitions[1].Width = new GridLength(0, GridUnitType.Pixel);
                        grid.ColumnDefinitions[2].Width = new GridLength(0, GridUnitType.Pixel);
                    }
                    else
                    {
                        grid.ColumnDefinitions[1].Width = new GridLength(5, GridUnitType.Pixel);
                        grid.ColumnDefinitions[2].Width = new GridLength(1, GridUnitType.Star);
                    }
                }

                var pge = editor as IPropertyGridEditor;
                if (pge != null)
                {
                    if (!pge.SetContext(property, parameter))
                    {
                        return(null);
                    }
                }
            }
            return(editor);
        }