This is a migrated thread and some comments may be shown as answers.

RadMaskedCurrencyInput does not Update Property when Delete Key is pressed

5 Answers 93 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Sagar
Top achievements
Rank 1
Sagar asked on 25 Aug 2015, 06:57 AM

Hi,

 I have below code implemented, which shows the formatted value.

<telerik:RadMaskedCurrencyInput x:Name="uxCurrency" Grid.Row="8" Grid.Column="1" Margin="2,1" Width="170" Style="{StaticResource RadMaskedCurrencyInputStyle}" Validation.ErrorTemplate="{x:Null}" FormatString="c"
UpdateValueEvent="PropertyChanged" MaskedInput:MaskedInputExtensions.Maximum="9999999999.99" MaskedInput:MaskedInputExtensions.Minimum="0"
Value="{Binding CurrencyProperty,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True}"
MaskedInput:MaskedInputExtensions.IsEditorTabStop="True"/>
 

my query here is,  the control does not update Property, when user hits "Delete" / "Backspace" Keyboard button. What is the possible workaround here?

 

Note: I don't want to use the "_" or " " mask here

 

I came across "IsValueChangingFromInternal " property of InputBase, but didn't get enough documentation or samples around it to figure out, if i could use that.

Can you please help me resolve the issue?

 

Thanks in Advance :)

Sagar

 

 

 

 

5 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 26 Aug 2015, 07:06 AM
Hello Sagar,

Could you please give us some test cases we can investigate ? For example the Value is 12345.67 the cursor is between 2 and 3 and you press backspace or delete. Let us know in these scenarios what is the exact cursor position and the value you expect. Also, we need the style setters from your "RadMaskedCurrencyInputStyle". Thank you in advance for your cooperation.

Additionaly, we believe eveything could be achieved with no-mask and formatstring and extension properties. Could you please elaborate more on the reasons you cannot use no-mask feature ?

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Sagar
Top achievements
Rank 1
answered on 26 Aug 2015, 07:29 AM

Hi Peter,

  Essentially, i am looking for a use case, where user selects the entire Text on the control, through Tab in to the control or similar, and Hits Keyboard key Delete / Backspace, provided the Text has 0.00 or 0 in it (which is a default value). The background property's Setter is not getting triggered.

 

<Setter Property="FontFamily" Value="Verdana"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="MinHeight" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="Padding" Value="2,0,2,2" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="HorizontalAlignment"  Value="Left"/>
<Setter Property="VerticalAlignment"  Value="Center"/>
<Setter Property="HorizontalContentAlignment"  Value="Left"/>
<Setter Property="VerticalContentAlignment"  Value="Center"/>
<Setter Property="IsCurrencySymbolVisible"  Value="True"/>
<Setter Property="IsClearButtonVisible"  Value="False"/>
<Setter Property="AutoFillNumberGroupSeparators"  Value="False"/>
<Setter Property="AutoFillZeros"  Value="False"/>
<Setter Property="Culture"  Value="en-US"/>
<Setter Property="InputBehavior"  Value="Insert"/>
<Setter Property="Mask"  Value=""/>
<Setter Property="SelectionOnFocus"  Value="SelectAll"/>
<Setter Property="TextMode"  Value="PlainText"/>
<Setter Property="IsLastPositionEditable"  Value="False"/>
<Setter Property="IsTabStop"  Value="False"/>
<Setter Property="SectionsNavigationMode"  Value="None"/>

Control Template Triggers:

<ControlTemplate.Triggers>
                       <Trigger Property="IsMouseOver" Value="True">
                           <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource TextBox_MouseOver_Background}"/>
 
                       </Trigger>
                       <Trigger Property="IsFocused" Value="True">
                           <Setter Property="BorderBrush" TargetName="Border" Value="{StaticResource TextBox_MouseOver_Background}"/>
 
                       </Trigger>
                       <Trigger Property="IsEnabled" Value="False">
                           <Setter TargetName="Border" Property="Background" Value="{StaticResource TextBox_Disabled_Background}" />
                           <Setter Property="Foreground" Value="{StaticResource TextBox_Disabled_Foreground}" />
                           <Setter TargetName="Border" Property="BorderThickness" Value="1" />
                           <Setter Property="Opacity" Value="20" />
                       </Trigger>
 
                   </ControlTemplate.Triggers>
 

Please let me know, if anymore information required.

 

Thank you,

Sagar

0
Petar Mladenov
Telerik team
answered on 26 Aug 2015, 09:27 AM
Hi Sagar,

Thank you for the additional code. I added the style setters and used them. When the MaskedInput gets focused, SelectAll is performed and if you press delete or backspace - the Value is getting Null and the control becomes blank / empty which is expected. As I managed to understand you need to revert to 0.00 or 0 when you press the backspace or delete key in this scenarios. If so, you can try setting:
maskedInput:MaskedInputExtensions.AllowNull="False"

Let me know if this is what you needed.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Sagar
Top achievements
Rank 1
answered on 26 Aug 2015, 09:56 AM

Setting above property, does put the default value back in the control text. In my scenario, i want to set some other property in view model, if user Deletes the value from control Text, even after user tries to Delete 0 (To Enable some flag, which represents, Change occurred on View).

The solution above is helpful, but doesn't completely resolve my requirement.

 

Thank you,

Sagar

0
Petar Mladenov
Telerik team
answered on 27 Aug 2015, 12:18 PM
Hi Sagar,

Generally if you need to edit the value while you type (we can call this coerce),  you can use the PreviewValueChanged event in code behind or the ViewModels' property  which is bound to the Value property pf the MasledInput. Could you please elaborate more on the difficulties you experience in implementing such approach ? This way we would be better able to advice you.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Sagar
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Sagar
Top achievements
Rank 1
Share this question
or