public static void BindProperty(FrameworkElement element, BindableProperty property)
        {
            Guard.ArgumentNotNull(element, "element");

            var enabledBinding = new Binding("ReadOnly");
            enabledBinding.Converter = new BooleanInverseConverter();
            enabledBinding.Source = property;
            element.SetBinding(UIElement.IsEnabledProperty, enabledBinding);

        }
        ///<summary>
        /// Evaluates a bindable property to determine if the bindable is marked with <see cref="Common.Configuration.Design.EditorWithReadOnlyTextAttribute"/>.
        ///</summary>
        ///<param name="bindableProperty">The property to evaluate.</param>
        ///<returns>
        /// Returns <see langword="true"/> if the bindable indicates the text on an editor should only be editable from a popup editor.<br/>
        /// Otherwise, returns <see langword="false"/>.
        /// </returns>
        public static bool IsTextReadOnly(BindableProperty bindableProperty)
        {
            var textReadOnlyAttribute = bindableProperty.Attributes
                .OfType<Common.Configuration.Design.EditorWithReadOnlyTextAttribute>()
                .FirstOrDefault();

            if (textReadOnlyAttribute == null)
                return false;

            return textReadOnlyAttribute.ReadonlyText;
        }
        protected override void Arrange()
        {
            base.Arrange();

            mockIUIService = new Mock<IUIServiceWpf>();
            mockIUIService.Setup(x => x.ShowDialog(It.IsAny<TextEditDialog>()))
                .Callback<Window>(w => ((PopupEditorValue)w.DataContext).Value = "NewValue")
                .Returns(false).Verifiable("Dialog not shown.");

            mockService = new Mock<IServiceProvider>();
            mockService.Setup(x => x.GetService(It.Is<Type>(t => t == typeof(IUIServiceWpf))))
                .Returns(mockIUIService.Object);

            bindable = new BindableProperty(new MockProperty(mockService.Object, null, null));

            mockTypeDescriptor = new Mock<ITypeDescriptorContext>();
            mockTypeDescriptor.Setup(x => x.PropertyDescriptor).Returns(bindable);
        }
        void CustomAttributesEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            property = (BindableProperty)e.NewValue;
            CustomEditorBinder.BindProperty(this, property);

            NameValueCollection value = (NameValueCollection)property.Value;
            list = new ObservableCollection<KeyValueItem>();
            foreach (string key in value)
            {
                var item = new KeyValueItem { Key = key, Value = value[key] };
                item.DeleteCommand = new KeyValueItemDeleteCommand(this, item);
                ChangeMonitor monitor = new ChangeMonitor(this, item);
                monitor.PropertyChanged += new PropertyChangedEventHandler(monitor_PropertyChanged);
                changeMonitors.Add(monitor);
                list.Add(item);
            }

            AddNewItem();

            this.Items.ItemsSource = list;
        }