Custom PartEditBox Binding Value during user input

Editors for WPF Forum

Posted 10 years ago by Ruslan Fedoseienko
Version: 14.2.0610
Avatar

I have a custom PartEditBox control made by example of SSN editbox.

It has only 2 parts:

1. Dirrection: +/- (forward/bacward)

2. Length: long.MinValue < any number   < long.MaxValue

So the problem is that I want to validate user input on the fly because it is the only focusable control on the dialog (also it have two buttons).

But binding to model preperty only occures on focus lost. 

How this behaviour can be changed?

Some pice code:

XAML

<Window.Resources>
<Style TargetType="{x:Type parts:RelativeDistancePartBase}"
			BasedOn="{StaticResource {x:Type editors:Part}}">

            <!-- Inherited properties -->
            <Setter Property="IsInitialValueAutoUpdated"
				Value="{Binding ParentGroup.IsInitialValueAutoUpdated, RelativeSource={RelativeSource Self}}" />
            <Setter Property="IsNullAllowed"
				Value="{Binding ParentGroup.IsNullAllowed, RelativeSource={RelativeSource Self}}" />
            <Setter Property="PartValueCancelTriggers"
				Value="{Binding ParentGroup.PartValueCancelTriggers, RelativeSource={RelativeSource Self}}" />
            <Setter Property="PartValueCommitTriggers"
				Value="{Binding ParentGroup.PartValueCommitTriggers, RelativeSource={RelativeSource Self}}" />

            <!-- Control template -->
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type parts:RelativeDistancePartBase}">
                        <Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <editors:MaskedTextBox x:Name="PART_MaskedTextBox"
								Style="{DynamicResource {x:Static themes:EditorsResourceKeys.MaskedTextBoxEmbeddedStyleKey}}"
								Focusable="{Binding IsEditable, RelativeSource={RelativeSource TemplatedParent}}" Margin="0"
								IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
								Mask="{Binding Mask, RelativeSource={RelativeSource TemplatedParent}}"
								Text="{editors:SyncBinding StringValue, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

 <relativeDistancetEditBox:RelativeDistancetEditBox x:Name="_distanceEditor" Width="200" Margin="0,7,0,0" HorizontalAlignment="Left" Height="20"
                CheckBoxVisibility="Collapsed"
                SpinnerVisibility ="Visible"
                MaxDistance="{Binding Path=ItemsCount}"                                                           
                IsInitialValueAutoUpdated="False"
                Value="{Binding DistanceStr}"/>

Comments (1)

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

Hello,

The edit box's PartValueCommitTriggers property defaults to PartValueCommitTriggers.SpinnerChangeOrEnterKeyDown.  Have you tried setting it to PartValueCommitTriggers.All?


Actipro Software Support

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.