How to goto last inserted chars or select all inserted chars

8 posts, 1 answers
  1. Dario Concilio
    Dario Concilio avatar
    128 posts
    Member since:
    Apr 2016

    Posted 08 Nov Link to this post

    Hi to all,

    I'm seeing a demo, I would to goto at last char, but not last char of mask.

    I try to explane more clearly, I have example that I attached, when I get focus of control, Carrer appears at first position, I have a value of some characters and thay are less than max length of mask (a20), if a try to press "End", it goto to last char of mask, I would to goto at last inserted char.

    Other question, how can I select all, but only inserted value?

     

    SelectionOnFocus gives me several mode when I get focous, it would be nice to have "SelectAllValue" or "CarretToEndValue"

    Can I do it or custom it?

  2. Milena
    Admin
    Milena avatar
    201 posts

    Posted 11 Nov Link to this post

    Hello Dario,

    From your explanation and pictures I suppose that you are using RadMaskedTextInputt with Mask="a20". In this case the behavior you are observing is expected, because the placeholders (not only the mask value) are considered as chars. I could suggest you another approach to get the described behavior. You can use nomask (Mask="") and setting MaxTextLenght to 20 in order to achieve the same restriction for user input: 
    <telerik:RadMaskedTextInput Value="text" maskedInput:MaskedInputExtensions.MaxTextLength="20"
    Mask="" SelectionOnFocus="CaretToEnd"/>
     
    <telerik:RadMaskedTextInput Value="text" maskedInput:MaskedInputExtensions.MaxTextLength="20" Mask="" SelectionOnFocus="SelectAll"/>

    This way when the focus is on the maskedinput the caret will be to the end of the vale (when  SelectionOnFocus is set to "CaretToEnd") or will select all the value (when SelectionOnFocus is set to "SelectAll").

    Please let us know if this works for you. 


    Regards,
    Milena
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dario Concilio
    Dario Concilio avatar
    128 posts
    Member since:
    Apr 2016

    Posted 16 Nov in reply to Milena Link to this post

    I see, but how can I include "maskedInput:MaskedInputExtensions.MaxTextLength" into a Style?
  5. Milena
    Admin
    Milena avatar
    201 posts

    Posted 18 Nov Link to this post

    Hello Dario,

    you can set MaxTextLength property like this:
    <Window ...
            xmlns:maskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input">
    <Window.Resources>
      <Style TargetType="telerik:RadMaskedTextInput">
        <Setter Property="maskedInput:MaskedInputExtensions.MaxTextLength" Value="20"/>
      </Style>
    </Window.Resources>

     I hope this information helps.

    Regards,
    Milena
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
  6. Dario Concilio
    Dario Concilio avatar
    128 posts
    Member since:
    Apr 2016

    Posted 18 Nov in reply to Milena Link to this post

    Ok perfect.

    If user insert an underscore character and he comes out from MaskedTextInput, this character disappears, what can I do to resolve this issue?

  7. Dario Concilio
    Dario Concilio avatar
    128 posts
    Member since:
    Apr 2016

    Posted 18 Nov in reply to Dario Concilio Link to this post

    Ehm... sorry

    I'm using these setters

    <Style x:Key="FieldRadMaskedTextInputStyle" TargetType="telerik:RadMaskedTextInput" BasedOn="{StaticResource RadMaskedTextInputStyle}">
            <Setter Property="Margin" Value="5"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="TextMode" Value="PlainText"/>
            <Setter Property="SpinMode" Value="None"/>
            <Setter Property="SelectionOnFocus" Value="CaretToBeginning"/>
            <Setter Property="UpdateValueEvent" Value="PropertyChanged"/>
            <Setter Property="InputBehavior" Value="Replace"/>
            <Setter Property="EmptyContent" Value=""/>
            <Setter Property="Mask" Value=""/>
            <Setter Property="SectionsNavigationMode" Value="None"/>
            <Setter Property="IsClearButtonVisible" Value="False"/>
  8. Answer
    Milena
    Admin
    Milena avatar
    201 posts

    Posted 22 Nov Link to this post

    Hello Dario, 

    Thank you for reporting this issue. I logged it in our Feedback portal where you can track its progress. I have also updated your Telerik points as a small appreciation for your cooperation.

    In the meantime, as a workaround you can set Placeholder property to empty string ( <Setter Property="Placeholder" Value=""/>). The issue is caused by the fact that the default value of Placeholder  property is underscore. It would be expected behavior if the mask is different then NoMask(Mask=""), but in this case we can confirm that it is a bug.

    Please excuse us for any inconvenience caused.

    Regards,
    Milena
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
  9. Dario Concilio
    Dario Concilio avatar
    128 posts
    Member since:
    Apr 2016

    Posted 23 Nov in reply to Milena Link to this post

    It works! Thank you.
Back to Top
UI for WPF is Visual Studio 2017 Ready