property editor for enum

Grids for WPF Forum

Posted 12 years ago by Mary Fontana - Rudolph Technologies
Avatar
I am setting a TypeConverter for an enum property as in one of your samples.
I don't set the Editor for the enum property. But I think by default is uses the ComboBoxStringPropertyEditor.
I have a request for the drop down list to open if you select the property field.
instead of having to select the dropdown list button on the right.

Or could I move the button to the left instead?

I looked at PropertyEditors.xaml but I don't see an editor that matches the behavior I am seeing.

Thanks,
Mary

Comments (4)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mary,

By default the DynamicValueTemplateKey property editor is used, which ultimately uses a ComboBox/TextBox. You would have to build a custom property editor to achieve that behavior, but it could be based on our property editor. Effectively, you'd have to build/style a ComboBox that looks and feels like you want, then build a property editor that uses your custom style/template.


Actipro Software Support

Posted 12 years ago by Mary Fontana - Rudolph Technologies
Avatar
I am confused. Is there a property being set on the ComboBox in DynamicValueTemplateKey that causes you to have to click on the pulldown arrow on right to show the list?
When I use a ComboBox in other parts of my applicaion you can click anywhere in the ComboBox and the pulldown list is displayed.
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mary,

Sorry, I was more referring to having the button on the left. By default, our DynamicValueTemplateKey sets IsEditable to true and will toggle IsReadOnly based on whether the user can enter free form text. This allows the end-user to still select and copy values and provides a consistent look, even in Aero where the non-editable ComboBoxes look like buttons.

You could redefine our DynamicValueTemplateKey to toggle IsEditable instead, or build a custom property editor as needed. Assuming you are using WPF Studio 2011.2 build 0551, then the following should work if you add to your application resources:
<!-- DynamicValueTemplateKey -->
<DataTemplate x:Key="{x:Static propgrid:BuiltinEditors.DynamicValueTemplateKey}">
    <Grid x:Name="grid">
        <ComboBox x:Name="comboBox" Margin="0" Padding="0" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" Background="Transparent"
                ItemsSource="{Binding StandardValues, RelativeSource={RelativeSource AncestorType={x:Type propgridPrimitives:IPropertyDataAccessor}}}" />
        <TextBox x:Name="textBox" Margin="0" Padding="0"  
                BorderThickness="0" Background="Transparent" MaxLines="1" Visibility="Collapsed" />
    </Grid>

    <DataTemplate.Triggers>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding Visibility, ElementName=comboBox}" Value="Visible" />
                <Condition Binding="{Binding IsLimitedToStandardValues, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}}"
                        Value="false" />
            </MultiDataTrigger.Conditions>
            <Setter TargetName="comboBox" Property="IsEditable" Value="true" />
            <Setter TargetName="comboBox" Property="Text"
                    Value="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
        </MultiDataTrigger>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding Visibility, ElementName=comboBox}" Value="Visible" />
                <Condition Binding="{Binding IsLimitedToStandardValues, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}}"
                        Value="true" />
            </MultiDataTrigger.Conditions>
            <Setter TargetName="comboBox" Property="SelectedItem"
                    Value="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
        </MultiDataTrigger>
        <DataTrigger Binding="{Binding Visibility, ElementName=textBox}" Value="Visible">
            <Setter TargetName="textBox" Property="Text"
                    Value="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
        </DataTrigger>
        <DataTrigger Binding="{Binding HasItems, ElementName=comboBox}" Value="false">
            <Setter TargetName="comboBox" Property="Visibility" Value="Collapsed" />
            <Setter TargetName="textBox" Property="Visibility" Value="Visible" />
        </DataTrigger>
        <DataTrigger
                Binding="{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}}"
                Value="true">
            <Setter TargetName="comboBox" Property="Visibility" Value="Collapsed" />
            <Setter TargetName="textBox" Property="Visibility" Value="Visible" />
            <Setter TargetName="textBox" Property="IsReadOnly" Value="true" />
            <Setter TargetName="textBox" Property="Foreground" Value="{DynamicResource {x:Static themes:AssetResourceKeys.ControlForegroundDisabledBrushKey}}" />
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=(propgrid:PropertyGrid.IsReadOnly), RelativeSource={RelativeSource Self}}"
                Value="true">
            <Setter TargetName="comboBox" Property="Visibility" Value="Collapsed" />
            <Setter TargetName="textBox" Property="Visibility" Value="Visible" />
            <Setter TargetName="textBox" Property="IsReadOnly" Value="true" />
            <Setter TargetName="textBox" Property="Foreground" Value="{DynamicResource {x:Static themes:AssetResourceKeys.ControlForegroundDisabledBrushKey}}" />
        </DataTrigger>
    </DataTemplate.Triggers>
</DataTemplate>


Actipro Software Support

Posted 12 years ago by Mary Fontana - Rudolph Technologies
Avatar
That worked. Thank you very much.
The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.