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

RadMaskedCurrencyInput backspace error

6 Answers 139 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 10 Sep 2013, 02:32 PM
Hello,

Basically I am positioning the cursor in the box mid way though a number and then just holding down backspace and I get an IndexOutOfRangeException which says "Index was outside the bounds of the array.". I do have a screencast of me creating the error if you need that.

Here is the xaml:

<telerik:RadMaskedCurrencyInput Grid.Row="5" Grid.Column="3" Value="{ Binding BgsStepBase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Style="{ StaticResource StandardRadMaskedCurrencyInput}" Validation.ErrorTemplate="{ StaticResource RadMaskedCurrencyInputErrorTemplate}" IsClearButtonVisible="True" IsReadOnly="{Binding IsBgsFieldEnabled, Converter={StaticResource NotConverter}}" FormatString="n0" />

The bound value is decimal? (nullable decimal).

The stack trace is:

   at Telerik.Windows.Controls.RadMaskedInputBase.FindPreviousAvailablePositionNoMask() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedInputBase.NoMask.cs:line 209
   at Telerik.Windows.Controls.RadMaskedCurrencyInput.HandleBackKeyNoMask() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedCurrencyInput.NoMask.cs:line 120
   at Telerik.Windows.Controls.RadMaskedInputBase.HandleBackKey() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedInputBase.cs:line 2154
   at Telerik.Windows.Controls.RadMaskedInputBase.OnKeyDown(Object sender, KeyEventArgs e) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedInputBase.cs:line 1701
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at GH.WPF.App.App.Main() in C:\DevWork\Cubit2\Dev\Features\CommonPartEnhancementV1\GH.WPF.Cubit2\obj\x86\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()



Thanks,

Alex

6 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 13 Sep 2013, 11:50 AM
Hi Alex,

I tested the snippet that you provided with our latest official release on our side and it seems that the code works as expected. I would like to know which version of our controls you use.

on the other hand, is it possible for you to try to reproduce the reported issue in a separate project and send it over? By doing so I will be able to fully understand your scenario and investigate the reasons behind the issue.

Thank you for your kind cooperation.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jason
Top achievements
Rank 1
answered on 24 Oct 2013, 01:11 PM
Hello


We have the same problem with the latest version of telerik MaskedInputNumericControl(2013.3.1016.40).
Properties from style:
<Setter Property="IsTabStop" Value="False" />
<Setter Property="UpdateValueEvent" Value="LostFocus"/>
<Setter Property="TextMode" Value="PlainText"/>
        <Setter Property="IsClearButtonVisible" Value="False"/>
        <Setter Property="Placeholder" Value="_"/>
        <Setter Property="Mask" Value=""/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="AcceptsReturn" Value="False"/>
        <Setter Property="SelectionOnFocus" Value="Unchanged"/>
        <Setter Property="SpinMode" Value="None"/>
        <Setter Property="InputBehavior" Value="Insert"/>
        <Setter Property="SectionsNavigationMode" Value="None"/>


Example:
<telerik:RadMaskedNumericInput x:Name="edtTextBoxControl" Margin="5,0,3,3" MinWidth="50" MaxWidth="50"
                                      HorizontalAlignment="Left"
 VerticalAlignment="Center"
                                      Value="{Binding Value,UpdateSourceTrigger=PropertyChanged}"/>
wwhere Value is of type interger .


Steps:

- Enter large value - (9.86767676767676E+76)
- Press Backspace
- Get exception

Type : System.IndexOutOfRangeException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Index was outside the bounds of the array.
Source : Telerik.Windows.Controls.Input
Help link : 
Data : System.Collections.ListDictionaryInternal
TargetSite : Int32 FindPreviousAvailablePositionNoMask()
HResult : -2146233080
Stack Trace :    at Telerik.Windows.Controls.RadMaskedInputBase.FindPreviousAvailablePositionNoMask()
   at Telerik.Windows.Controls.RadMaskedNumericInput.HandleBackKeyNoMask()
   at Telerik.Windows.Controls.RadMaskedInputBase.HandleBackKey()
   at Telerik.Windows.Controls.RadMaskedInputBase.OnKeyDown(Object sender, KeyEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
0
Jason
Top achievements
Rank 1
answered on 28 Oct 2013, 02:56 PM
Hello

Some details:

- Enter value 8.77777888888888E+88
- Move caret to the end of text input
- Press Backspace and you will get error


The bug can be duplicated only if UpdateValueEvent=PropertyChanged

<Window x:Class="IndexOutOfRangeExceptionMaskedNumeric.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:a="clr-namespace:IndexOutOfRangeExceptionMaskedNumeric"
        xmlns:maskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input"
        xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <maskedInput:HorizontalContentAlignmentToTextAlignmentConverter x:Key="conv"/>
        <a:Boolean2VisibilityConverter x:Key="boolToVisConverter"/>
        <Style x:Key="TextBoxStyle" TargetType="maskedInput:PreviewInputTextBox">
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="maskedInput:PreviewInputTextBox">
                        <Grid x:Name="RootElement"  Background="Transparent">
                            <ScrollViewer
Padding="{TemplateBinding Padding}" Background="Transparent" BorderThickness="0"
Foreground="{TemplateBinding Foreground}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            x:Name="PART_ContentHost"
                            />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="RadMaskedInputBaseStyle" TargetType="telerikInput:RadMaskedInputBase">
           
            <Setter Property="IsReadOnly" Value="False" />
            <Setter Property="MinHeight" Value="22" />
            <Setter Property="MinWidth" Value="15"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="UpdateValueEvent" Value="LostFocus"/>
            <Setter Property="TextMode" Value="PlainText"/>
            <Setter Property="IsClearButtonVisible" Value="False"/>
            <Setter Property="Placeholder" Value="_"/>
            <Setter Property="Mask" Value=""/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="AcceptsReturn" Value="False"/>
            <Setter Property="SelectionOnFocus" Value="Unchanged"/>
            <Setter Property="SpinMode" Value="None"/>
            <Setter Property="InputBehavior" Value="Insert"/>
            <Setter Property="SectionsNavigationMode" Value="None"/>
            <Setter Property="Margin" Value="3,1"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="EmptyContent" Value="Enter text here"/>
            <Setter Property="UpdateValueEvent" Value="PropertyChanged"/>
            <Setter Property="Validation.ErrorTemplate">
                <Setter.Value>
                    <ControlTemplate x:Name="InspectorErrorTemplate">
                        <StackPanel Orientation="Vertical">
                            <Border BorderBrush="Red" BorderThickness="1">
                                <AdornedElementPlaceholder Name="adornerPlaceholder"/>
                            </Border>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="TextBoxStyle" Value="{StaticResource TextBoxStyle}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="telerikInput:RadMaskedInputBase">
                        <Grid SnapsToDevicePixels="True">

                            <Border BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
CornerRadius="3"
BorderBrush="{TemplateBinding BorderBrush}" 
x:Name="InnerBorder">
                                <Grid>
                                    <TextBlock x:Name="WatermarkText" 
  Margin="3,0,0,0"
  Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={a:GetWatermarkTextConverter}}" 
  Visibility="Collapsed" 
  VerticalAlignment="Center"
/>
                                    <maskedInput:PreviewInputTextBox x:Name="EditorSite"
TabIndex="{TemplateBinding TabIndex}" 
                                    Cursor="{TemplateBinding Cursor}"
                                    IsTabStop="True" AcceptsReturn="{TemplateBinding AcceptsReturn}"
                                    IsEnabled="{TemplateBinding IsEnabled}"
                                    Foreground="{TemplateBinding Foreground}"
                                    IsReadOnly="{TemplateBinding IsReadOnly}"
                                    Padding="{TemplateBinding Padding}"
                                    Height="{TemplateBinding Height}"
                                    TextAlignment="{Binding HorizontalContentAlignment, Converter={StaticResource conv}, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Style="{TemplateBinding TextBoxStyle}"
                                    FontFamily="{TemplateBinding FontFamily}"
                                    FontSize="{TemplateBinding FontSize}"
                                    FontWeight="{TemplateBinding FontWeight}"/>
                                </Grid>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>

<!--                            <Trigger Property="IsEnabled" Value="False">-->
<!--                                <Setter Property="Foreground" TargetName="EditorSite"-->
<!-- Value="{StaticResource DisabledControlsForegroundBrush}" />-->
<!--                                <Setter Property="BorderBrush" TargetName="InnerBorder"-->
<!-- Value="{StaticResource DisabledControlsBorderBrush}" />-->
<!--                                <Setter Property="Background" TargetName="InnerBorder"-->
<!-- Value="{StaticResource DisabledControlsBackgroundBrush}" />-->
<!--                            </Trigger>-->
<!--                            <Trigger Property="IsReadOnly" Value="True">-->
<!--                                <Setter Property="Foreground" TargetName="EditorSite"-->
<!-- Value="{StaticResource ReadOnlyControlsForegroundBrush}" />-->
<!--                                <Setter Property="BorderBrush" TargetName="InnerBorder"-->
<!-- Value="{StaticResource ReadOnlyControlsBorderBrush}" />-->
<!--                                <Setter Property="Background" TargetName="InnerBorder"-->
<!-- Value="{StaticResource ReadOnlyControlsBackgroundBrush}" />-->
<!--                            </Trigger>-->

                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsKeyboardFocusWithin" Value="True" />
                                    <Condition Property="IsReadOnly" Value="False" />
                                    <Condition Property="IsEnabled" Value="True" />
                                </MultiTrigger.Conditions>
                                <Setter Property="BorderBrush" TargetName="InnerBorder" Value="Black"/>
                            </MultiTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Value, Converter={a:IsNullOrEmptyToBooleanConverter}}" Value="True"/>
                                    <Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsKeyboardFocusWithin}" Value="False"/>
                                    <Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsReadOnly}" Value="False"/>
                                    <Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsEnabled}" Value="True"/>
                                </MultiDataTrigger.Conditions>
                                <Setter TargetName="WatermarkText" Property="Visibility" Value="Visible"/>
                            </MultiDataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="telerikInput:RadMaskedTextInput" BasedOn="{StaticResource RadMaskedInputBaseStyle}">
        </Style>
        <Style TargetType="telerikInput:RadMaskedNumericInput" BasedOn="{StaticResource RadMaskedInputBaseStyle}">
        </Style>
        <Style TargetType="telerikInput:RadMaskedDateTimeInput" BasedOn="{StaticResource RadMaskedInputBaseStyle}">
        </Style>
        <Style TargetType="telerikInput:RadMaskedCurrencyInput" BasedOn="{StaticResource RadMaskedInputBaseStyle}">
        </Style>
    </Window.Resources>
    <Grid>
        <telerikInput:RadMaskedNumericInput x:Name="edtTextBoxControl" Style="{StaticResource RadMaskedInputBaseStyle}"
                                      HorizontalAlignment="Left"
 VerticalAlignment="Center"
                                      Value="{Binding Interval,UpdateSourceTrigger=PropertyChanged}"
 
/>
    </Grid>
</Window>

public class WatermarkText : DependencyObject
{
public static string GetText(DependencyObject obj)
{
string watermarkText = (string)obj.GetValue(TextProperty);
if (watermarkText == defaultString)
{
if (obj is ComboBox)
watermarkText = "Select an Item";
else if (obj is RadTimePicker)
watermarkText = "Enter time";
else if (obj is RadDateTimePicker || obj is RadDatePicker)
watermarkText = "Enter date";
else
watermarkText = "Enter text here";
}
return watermarkText;
}
public static void SetText(DependencyObject obj, string value)
{
obj.SetValue(TextProperty, value);
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.RegisterAttached("Text", typeof(string), typeof(WatermarkText), new FrameworkPropertyMetadata(defaultString));

private const string defaultString = "++WatermarkDefaultText++";
}
public class GetWatermarkTextConverter : MarkupExtension, IValueConverter
{
public override object ProvideValue(IServiceProvider serviceProvider)
{
return new GetWatermarkTextConverter();
}

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is DependencyObject)
return WatermarkText.GetText((DependencyObject)value);
else
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
public class Boolean2VisibilityConverter : MarkupExtension, IValueConverter
{
public override object ProvideValue(IServiceProvider serviceProvider)
{
return new BooleanToVisibilityConverter();
}

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool)
return ((bool)value) ? Visibility.Visible : Visibility.Collapsed;
else
return Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Visibility)
return ((Visibility)value) == Visibility.Visible ? true : false;
else
return false;
}
}
public class IsNullOrEmptyToBooleanConverter : MarkupExtension, IValueConverter
{
public IsNullOrEmptyToBooleanConverter() { }

public override object ProvideValue(IServiceProvider serviceProvider)
{
return new IsNullOrEmptyToBooleanConverter();
}

#region IValueConverter Members

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return true;

if (value is string)
{
bool f = String.IsNullOrEmpty((string)value);
if (!f)
f = String.IsNullOrWhiteSpace((string)value);
return f;
}

if (value is IList)
{
return ((IList)value).Count == 0;
}

return value == null;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}

#endregion
}
0
Petar Mladenov
Telerik team
answered on 29 Oct 2013, 11:27 AM
Hi Jason and Alex,

 We managed to reproduce this Exception thanks to the provided info. We logged it in our PITS where you can track its status. We will do our best to have it fixed for the Service Pack next month.

Regards,
Petar Mladenov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Atiq
Top achievements
Rank 1
answered on 13 Dec 2013, 11:43 AM
Hi

is there any update on this?

regards
atiq
0
Petar Mladenov
Telerik team
answered on 13 Dec 2013, 02:02 PM
Hello Atiq,

Yes, the fix is already included in the Q3 2013 SP from Dec 4th (1204).

Regards,
Petar Mladenov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Alex
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Jason
Top achievements
Rank 1
Petar Mladenov
Telerik team
Atiq
Top achievements
Rank 1
Share this question
or