RadMaskedNumericInput - CaretToEnd won't place the caret at the when Mask=""

5 posts, 0 answers
  1. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 29 Nov 2013 Link to this post

    <Style TargetType="telerik:RadMaskedNumericInput">
              <Setter Property="FontWeight" Value="Normal" />
              <Setter Property="Width" Value="100" />
              <Setter Property="TextMode" Value="PlainText" />
              <Setter Property="IsClearButtonVisible" Value="True"/>
              <Setter Property="AllowSkipPlaceholders" Value="False"/>
              <Setter Property="AutoFillNumberGroupSeparators" Value="False"/>
              <Setter Property="SelectionOnFocus" Value="CaretToEnd"/>
              <Setter Property="HorizontalContentAlignment" Value="Left"/>
              <Setter Property="input:MaskedInputExtensions.Maximum" Value="99999"/>
              <Setter Property="Mask" Value=""/>
    </Style>

    The caret is always placed after the fist number when the control is on focus.
    I am using 2013 Q3 version
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 29 Nov 2013 Link to this post

    Hi Joel,

    You are right about this issue - the SelectionOnFocus does not work well if the Mask is "". However, if you need the caret to be placed at the end of the text in this scenario, you can try the following:
    • Remove the SelectionOnFocus setter.
    • Add this setting:
    <Setter Property="maskedInput:MaskedInputExtensions.CaretToEndOfTextOnFocus" Value="True"/>
    where maskedInput is defined like so:
    xmlns:maskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input"

    Please let us know if this helps you proceed further.

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 29 Nov 2013 Link to this post

    No, it does not work.
    I have ported your project to VS2010.
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 03 Dec 2013 Link to this post

    Hello Joel,

    We tested this more precisely and it appears that the logic of this properly is implemented only for MaskedTextInput. We logged a related item in our FeedBackPortal. As a workaround you can use MaskedTextInput instead of Numeric (and bind its value to double proeprty with Converter) or use the GotFocus event handler in order to place the SelectionStart (caret position properly).

    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 >>
  6. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 03 Dec 2013 Link to this post

    As a workaround, i have implemented something similar to this post:
    http://stackoverflow.com/questions/1647815/how-to-add-a-blend-behavior-in-a-style-setter

    <UserControl.Resources>
           <helper:Triggers x:Key="putCaretToEnd" x:Shared="False">
               <i:EventTrigger EventName="GotFocus">
                   <helper:PutCaretToEndAction/>
               </i:EventTrigger>
           </helper:Triggers>
     
           <Style x:Key="maskedNumInputStyle" TargetType="telerik:RadMaskedNumericInput">
               <Setter Property="FontWeight" Value="Normal" />
               <Setter Property="Width" Value="100" />
               <Setter Property="TextMode" Value="PlainText" />
               <Setter Property="IsClearButtonVisible" Value="True"/>
               <Setter Property="AllowSkipPlaceholders" Value="False"/>
               <Setter Property="AutoFillNumberGroupSeparators" Value="False"/>
               <Setter Property="HorizontalContentAlignment" Value="Left"/>
               <Setter Property="Mask" Value=""/>
               <!-- The CaretToEnd value is not working for SelectionOnFocus-->
               <!--<Setter Property="SelectionOnFocus" Value="CaretToEnd"/>-->
               <Setter Property="helper:SupplementaryInteraction.Triggers" Value="{StaticResource putCaretToEnd}"/>
           </Style>
       </UserControl.Resources>
Back to Top
UI for WPF is Visual Studio 2017 Ready