This project has moved and is read-only. For the latest updates, please go here.

Property Grid disable update on keystroke.

Apr 23, 2015 at 6:18 PM
Edited Apr 23, 2015 at 6:20 PM
I'm using version 2.4 of the community edition. I have a generic property grid with auto-generated properties. For my 'double' properties, every time I type in the editor box it triggers a value change. This in turn, auto-selects the text so that my next keystrokes overides it. So, if i want to type '123', the grid will update one '1', then override with '2' then override with '3'. So instead of 123, I get 3. How can I disable a trigger on every keystroke and only make it update when it loses focus or on 'Enter'?

Making a custom editor was unssucessful as it wasn't even recognized by property grid. This is related to this issue: https://wpftoolkit.codeplex.com/discussions/397185.

Basically, the propertygrid assembly doesn't have any reference to my external assembly where my selected object and it's custom editor are implemented. The object is sent to the propertygrid via EventAggregator.

How can I resolve this without implementing a custom ITypeEditor?
Developer
Apr 24, 2015 at 5:12 PM
Hi,

By default, for a property of type double, the editor in the propertyGrid will be a PropertyGridEditorDoubleUpDown, which is a DoubleUpDown.
Starting at v2.5, a new property is available for
-NumericUpDowns
-DateTimeUpDown
-DateTimePicker
-TimePicker
-TimeSpanUpDown

The new property is called "UpdateValueOnEnterKey" and is False by default. If you set it to true, the synchronization between "Value" and "Text" will only be done on a Enter key press, or a lostFocus.

So you could use a specific editor for double :
<toolkit:PropertyGrid x:Name="_propertyGrid"
                            PropertyValueChanged="_propertyGrid_PropertyValueChanged_1">
         <toolkit:PropertyGrid.EditorDefinitions>
            <toolkit:EditorTemplateDefinition TargetProperties="{x:Type sys:Double}">
               <toolkit:EditorTemplateDefinition.EditingTemplate>
                  <DataTemplate>
                     <toolkit:PropertyGridEditorDoubleUpDown UpdateValueOnEnterKey="True"
                                                             Value="{Binding Value}"/>
                  </DataTemplate>
               </toolkit:EditorTemplateDefinition.EditingTemplate>
            </toolkit:EditorTemplateDefinition>
         </toolkit:PropertyGrid.EditorDefinitions>
</toolkit:PropertyGrid>
I suggest you wait for the next community Edition : v2.5 or buy the Plus Edition, which is 2 versions ahead at v2.6 (with v2.7 to be released shortly).
You can find the Plus Edition here : https://wpftoolkit.codeplex.com/wikipage?title=Compare%20Editions