UpdateSourceTrigger for standart editor

Grids for WPF Forum

Posted 14 years ago by Aliaksei
Version: 9.1.0505
Avatar
Hi,
How I can change binding UpdateSourceTrigger property for standart editors.
I would like to change it to PropertyChanged value.

Thank you

Comments (5)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Unfortunately, you would have to redefine the property editors and change the UpdateSourceTrigger. If you are an existing customer you can use the default Styles as a basis.


Actipro Software Support

Posted 14 years ago by Aliaksei
Avatar
Yes we are existing customers.
I don't understand how we can override this logic by using default styles?
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
There isn't an easy setting or option that you can set to accomplish this. What you would need to do is copy the DataTemplates for the default property editors (which are defined in the files for the default Styles) and put those in your application/window resources. You would then have to manually add/update the UpdateSourceTrigger as you desire.

Once you have those defined in your application/window resources, the PropertyGrid should automatically pick them up (assuming you use the same ComponentResourceKey values). The DataTemplates are defined in the PropertyEditors.xaml file under the PropertyGrid resources.


Actipro Software Support

Posted 14 years ago by Aliaksei
Avatar
Hi,

I'm include in project templates from
ActiproXamlStyles-Source-9.1.0503\PropertyGrid\Themes\PropertyGrid\PropertyEditors.xaml
Then I add UpdateSourceTrigger=PropertyChanged like this

<!-- TextBoxValueTemplateKey -->
    <DataTemplate x:Key="{x:Static propgridEditors:BuiltinEditors.TextBoxValueTemplateKey}">
        <TextBox x:Name="textBox" Margin="0" Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                BorderThickness="0" Background="Transparent" MaxLines="1"
                Text="{Binding ValueAsString,UpdateSourceTrigger=PropertyChanged , RelativeSource={RelativeSource AncestorType={x:Type propgridPrimitives:IPropertyDataAccessor}}, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Converter={StaticResource NoOpConverter}}" />
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType={x:Type propgridPrimitives:IPropertyDataAccessor}}}"
                    Value="true">
                <Setter TargetName="textBox" Property="IsReadOnly" Value="true" />
                <Setter TargetName="textBox" Property="Foreground"
                        Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=(propgrid:PropertyGrid.IsReadOnly), RelativeSource={RelativeSource Self}}"
                    Value="true">
                <Setter TargetName="textBox" Property="IsReadOnly" Value="true" />
                <Setter TargetName="textBox" Property="Foreground"
                        Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
Then I add this file with templates to UserControl resources on which property grid is used.
Editors are set like this:

<propgrid:PropertyGrid Name="propGrid">
            
            <propgrid:PropertyGrid.PropertyEditors>
                    <propgrideditors:BrushPropertyEditor CheckBoxVisibility="Hidden" />
                    <propgrideditors:ColorPropertyEditor CheckBoxVisibility="Hidden" />
                    <propgrideditors:DateTimePropertyEditor CheckBoxVisibility="Visible" />
                    <propgrideditors:DoublePropertyEditor CheckBoxVisibility="Hidden" SpinnerVisibility="Visible" />
                    <propgrideditors:GuidPropertyEditor CheckBoxVisibility="Hidden" NewGuidButtonVisibility="Visible" />
                    <propgrideditors:Int32PropertyEditor CheckBoxVisibility="Hidden" SpinnerVisibility="Visible" />
                    <propgrideditors:Int32RectPropertyEditor CheckBoxVisibility="Hidden" SpinnerVisibility="Visible" />
                    <propgrideditors:NullableColorPropertyEditor CheckBoxVisibility="Visible"  />
                    <propgrideditors:NullableDateTimePropertyEditor CheckBoxVisibility="Visible" />
                    <propgrideditors:NullableDoublePropertyEditor CheckBoxVisibility="Visible" SpinnerVisibility="Visible" />
                    <propgrideditors:NullableGuidPropertyEditor CheckBoxVisibility="Visible" NewGuidButtonVisibility="Visible" />
                    <propgrideditors:NullableInt32PropertyEditor CheckBoxVisibility="Visible" SpinnerVisibility="Visible" />
                    <propgrideditors:NullableInt32RectPropertyEditor CheckBoxVisibility="Visible" SpinnerVisibility="Visible" />
                    <propgrideditors:NullablePointPropertyEditor CheckBoxVisibility="Visible" SpinnerVisibility="Visible" />
                    <propgrideditors:NullableRectPropertyEditor CheckBoxVisibility="Visible" SpinnerVisibility="Visible" />
                    <propgrideditors:NullableSizePropertyEditor CheckBoxVisibility="Visible" SpinnerVisibility="Visible" />
                    <propgrideditors:NullableTimeSpanPropertyEditor CheckBoxVisibility="Visible" />
                    <propgrideditors:NullableVectorPropertyEditor CheckBoxVisibility="Visible" SpinnerVisibility="Visible" />
                    <propgrideditors:PointPropertyEditor CheckBoxVisibility="Hidden" SpinnerVisibility="Visible" />
                    <propgrideditors:RectPropertyEditor CheckBoxVisibility="Hidden" SpinnerVisibility="Visible" />
                    <propgrideditors:SizePropertyEditor CheckBoxVisibility="Hidden" SpinnerVisibility="Visible" />
                    <propgrideditors:TimeSpanPropertyEditor CheckBoxVisibility="Hidden" />
                    <propgrideditors:VectorPropertyEditor CheckBoxVisibility="Hidden" SpinnerVisibility="Visible" />
                </propgrid:PropertyGrid.PropertyEditors>
            </propgrid:PropertyGrid>
But it still doesn't work. And I don't understand why file with templates doesn't contains templates for all editors (like guid editor....)? And what template is used for string properties?

Thank you for your help.
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi,

When you referred to the "standard editors", I thought you were referring to the default editors provided by the PropertyGrid for WPF product. Based on the above code, it looks like you are referring to the interop editors that tie in our Editors for WPF product with the PropertyGrid.

Those Styles are located under "Editors.Interop.PropertyGrid", but follow the same convention/concepts. If you send an email to our support address requesting the DataTemplate for the interop property editors, we can provide them to you.


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.