Hi Team,
I have an issue with xam numeric editor loosing focus which has a precision of two.When i enter the first digit the focus is lost.Not waiting for the second to enter.
Any help would be greatly appreciated.
Xaml Code:
<igEditors:XamNumericEditor HorizontalAlignment="Right" Grid.Column="3" InvalidValueBehavior="RevertValue" MinHeight="20" Height="25" Margin="3,0,3,0" IsAlwaysInEditMode="True" IsKeyboardFocusWithinChanged="UIElement_OnIsKeyboardFocusWithinChanged"> <igEditors:XamNumericEditor.Style> <Style TargetType="{x:Type igEditors:XamNumericEditor}" BasedOn="{StaticResource XamMaskedEditorBaseStyle}"> <Setter Property="Mask" Value="{}{double:2.0}"></Setter> <Setter Property="ValueType" Value="{x:Type sys:Decimal}"></Setter> <Setter Property="MinWidth" Value="25"></Setter> <Setter Property="IsAlwaysInEditMode" Value="True"></Setter> <Setter Property="Tag" Value="{Binding ElementName=UcTelemetryWorkspace}"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding IsChecked, ElementName=RbDataDensity}" Value="True"> <Setter Property="Mask" Value="{}{double:4.1}"></Setter> <Setter Property="Text" Value="{Binding Data.ExpectedDataDensity,UpdateSourceTrigger=PropertyChanged}" ></Setter> <Setter Property="ValueType" Value="{x:Type sys:Decimal}"></Setter> <Setter Property="MinWidth" Value="35"></Setter> <Setter Property="Width" Value="50"></Setter> </DataTrigger> <DataTrigger Binding="{Binding IsChecked, ElementName=RbRepeats}" Value="True"> <Setter Property="Text" Value="{Binding Data.RepeatData,UpdateSourceTrigger=PropertyChanged}" ></Setter> </DataTrigger> </Style.Triggers> </Style> </igEditors:XamNumericEditor.Style> <i:Interaction.Triggers> <i:EventTrigger EventName="KeyUp" > <i:InvokeCommandAction Command="{x:Static controller:JobConfigurationCreatorController.RefreshReportGraphCommand}" CommandParameter="{Binding ElementName=UcTelemetryWorkspace}"/> </i:EventTrigger> </i:Interaction.Triggers> <igEditors:XamNumericEditor.ValueConstraint> <igEditors:ValueConstraint MinInclusive="1" MaxInclusive="99"></igEditors:ValueConstraint> </igEditors:XamNumericEditor.ValueConstraint> </igEditors:XamNumericEditor>
Hello Sridhar,
I have created a sample project using the sample Style code that you have provided, replacing most of the StaticResources with my own resources, but I am still unable to reproduce the behavior in which the XamNumericEditor is losing focus after typing a single character. Being that your IsKeyboardFocusWithinChanged event is empty, I think it is safe to assume that this loss of focus is certainly coming from your command.
You have said that when this command fires - which it will with each key press when the XamNumericEditor is focused - that you are "refreshing" another control on another page. What is this control that you are refreshing, and how are you going about refreshing it? I ask, as I find it likely that this other control is getting focus, in which case the XamNumericEditor will lose focus. Would it be possible for you to please provide some more information on this?
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hi Andrew,
Here is the style :
1)Attached in the file
2)On key up button other control on the page gets refreshed .This is the exact place where the numeric editor looses focus.
.IsFocusable is set to false after other control is refreshed.
3)IsKeyboardFocusWithinChanged is an empy event.
Regards,
Sridhar
I have created a XamNumericEditor that mimics the one that you are using, but it does not lose focus after typing on my end. There is one thing I am mainly curious about in this case, though. I see that you have an EventTrigger for the KeyUp event hooked into a JobConfigurationCreatorController.RefreshReportGraph command. This will fire each time you type in the editor, and I believe this could be the source of this focusing behavior that you are seeing.
There are a couple of other things that I was missing, as well. For instance, I don't know what XamMaskedEditorBaseStyle entails, and I don't know what is happening in the IsKeyboardFocusWithinChanged event on your end.
Would it be possible for you to please provide some more information on these three points? Please let me know if you have any other questions or concerns on this matter.
<igEditors:XamNumericEditor HorizontalAlignment="Right" Grid.Column="3" InvalidValueBehavior="RevertValue"
MinHeight="20" Height="25" Margin="3,0,3,0" IsAlwaysInEditMode="True"
IsKeyboardFocusWithinChanged="UIElement_OnIsKeyboardFocusWithinChanged"> <igEditors:XamNumericEditor.Style> <Style TargetType="{x:Type igEditors:XamNumericEditor}"
BasedOn="{StaticResource XamMaskedEditorBaseStyle}"> <Setter Property="Mask" Value="{}{double:2.0}"></Setter> <Setter Property="ValueType" Value="{x:Type sys:Decimal}">
</Setter> <Setter Property="MinWidth" Value="25"></Setter> <Setter Property="IsAlwaysInEditMode" Value="True"></Setter> <Setter Property="Tag" Value="{Binding ElementName=UcTelemetryWorkspace}">
</Setter> <Style.Triggers> <DataTrigger Binding="{Binding IsChecked, ElementName=RbDataDensity}" Value="True"> <Setter Property="Mask" Value="{}{double:4.1}">
</Setter> <Setter Property="Text" Value="{Binding Data.ExpectedDataDensity,UpdateSourceTrigger=PropertyChanged}" ></Setter> <Setter Property="ValueType" Value="{x:Type sys:Decimal}">
</Setter> <Setter Property="MinWidth" Value="35">
</Setter> <Setter Property="Width" Value="50">
</Setter> </DataTrigger> <DataTrigger Binding="{Binding IsChecked, ElementName=RbRepeats}"
Value="True"> <Setter Property="Text"
Value="{Binding Data.RepeatData,UpdateSourceTrigger=PropertyChanged}" >
</Setter> </DataTrigger> </Style.Triggers> </Style> </igEditors:XamNumericEditor.Style> <i:Interaction.Triggers> <i:EventTrigger EventName="KeyUp" > <i:InvokeCommandAction Command="{x:Static controller:JobConfigurationCreatorController.RefreshReportGraphCommand}" CommandParameter="{Binding ElementName=UcTelemetryWorkspace}"/> </i:EventTrigger> </i:Interaction.Triggers> <igEditors:XamNumericEditor.ValueConstraint> <igEditors:ValueConstraint MinInclusive="1" MaxInclusive="99"></igEditors:ValueConstraint> </igEditors:XamNumericEditor.ValueConstraint> </igEditors:XamNumericEditor>