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}"/>