DialogTextBoxPropertyEditor Issue

Grids for WPF Forum

Posted 8 years ago by YN
Version: 11.2.0552

In my PropertyGrid, i will like to allow my user to "browse for a file".
To create the "..." button on the right-side, i used "DialogTextBoxPropertyEditor".
I will also want to make the "Editbox" on the PropertyGrid to be read-only.

I realized that if i set the Attribute of my variable to [ReadOny(true)], then the "EditBox" will be grayed out (which is what i want), but now we cannot modify the value using the "..." button.

Is there a way that this can be done?


Comments (1)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA

You would need to create a custom property editor. Our Property Editors QuickStart shows an example of a DataTemplate that includes a TextBox and a button, but you would need to add a resource like this:
<propgrid:PropertyGrid ... >
        <DataTemplate x:Key="MyEditor">
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                <TextBox Grid.Column="0" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        BorderThickness="0" IsReadOnly="True"
                        Text="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" />
                <shared:PopupButton Grid.Column="1" Content="..." DisplayMode="ButtonOnly"
                        Command="{x:Static sample:MainControl.ShowTextDialog}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}}" />
The command above is defined in the sample, but can be any custom command for which you handle and show the file dialog. You can then create a PropertyEditor for use with the EditorAttribute like so:
public class MyPropertyEditor : PropertyEditor {

    /// <summary>
    /// This property is not used by this class.
    /// </summary>
    /// <value><see langword="null"/>.</value>
    public override DataTemplate ValueTemplate {
        get { return null; }
        set { /* No-op */ }

    /// <summary>
    /// Gets or sets the resource key that references a <see cref="DataTemplate"/> for the value cell.
    /// </summary>
    /// <value>The resource key.</value>
    /// <remarks>
    /// The order of precedence for the name template selection is: <see cref="ValueTemplate"/>, <see cref="ValueTemplateSelector"/>,
    /// and finally <see cref="ValueTemplateKey"/>.
    /// </remarks>
    public override object ValueTemplateKey {
        get { return "MyEditor"; }

    /// <summary>
    /// This property is not used by this class.
    /// </summary>
    /// <value><see langword="null"/>.</value>
    public override DataTemplateSelector ValueTemplateSelector {
        get { return null; }
        set { /* No-op */ }


Actipro Software Support

The latest build of this product (v2019.1 build 0684) was released 14 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.