How to apply built-in editors

Grids for WPF Forum

Posted 15 years ago by Anurodh Ora
Version: 4.5.0482
Avatar
Hi,

Problem #1

I have bind the property grid with a data source.

But i am not able to apply build in editor like combo box and radio button on that.
However if I add items in XAML then it is being applied.

Please tell me where I am lacking to apply this.

Problem #2

How to apply activation gestures to make property editable like 'F2' etc.
Is there any special code to write?


Thanks

Anurodh

[Modified at 01/19/2009 09:27 AM]

[Modified at 01/19/2009 09:28 AM]

Comments (2)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Anurodh,

1. We would need a little more information to go on. If you can put together a small sample project and send that over to our support address, then we can take a look.

2. What exactly are you looking for here? Do you want the properties to be read-only until the user presses F2?


Actipro Software Support

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Anurodh,

#1. Based on your sample project, I'm assuming you want to define the property editors using code-behind (and not in XAML). If you want to define them in XAML, then the Property Editors QuickStart shows how to do this.

As for defining them in code-behind, you would need to update the PropertyGrid.PropertyEditors collection (preferably before you set SelectedObject(s), otherwise you will get an additional refresh as the new editors are applied). The following C# code will build a DataTemplate that uses the DateTimePicker from our Shared Library, and applies it to all DateTime properties.
FrameworkElementFactory factory = new FrameworkElementFactory(typeof(DateTimePicker));
factory.SetValue(DateTimePicker.MarginProperty, new Thickness(0));
factory.SetValue(DateTimePicker.IsEditableProperty, true);
factory.SetValue(DateTimePicker.BorderThicknessProperty, new Thickness(0));
factory.SetValue(DateTimePicker.ValueConverterParameterProperty, DateTimeToStringPattern.ShortDate);

RelativeSource relativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(IPropertyDataAccessor), 1);
factory.SetBinding(DateTimePicker.ValueProperty, new Binding("Value") { RelativeSource = relativeSource, Mode = BindingMode.TwoWay });

PropertyEditor propertyEditor = new PropertyEditor() { PropertyType = typeof(DateTime), ValueTemplate = new DataTemplate() { VisualTree = factory } };
propertyGrid11.PropertyEditors.Add(propertyEditor);
#2. Since you asked this question again in your other post, it will be answered there.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.