4 posts, 0 answers
  1. James
    James avatar
    2 posts
    Member since:
    Dec 2010

    Posted 02 Dec 2010 Link to this post

    We're evaluating Telerk controls. We have a requirement for users to be able to enter numeric values only. We don't want to see mask placeholders, and in most cases no spin control, but when we do use a spin control, obviously we'd like the look and feel to be identical. I'm not clear if we should be using the numeric up/down control always and we can hide the spin control as desired, or should be using the masked edit contol.

    For validation, we want to validate when the user attempts to change focus (mouse or keyboard), and force the focus to remain in the textbox if validation fails.

    Any information you can provide on how Telerk helps us meet these requirements would be appreciated.

  2. Boyan
    Boyan avatar
    758 posts

    Posted 07 Dec 2010 Link to this post

    Hello James,

    Thank you for your interest in Telerik Controls for WPF.

    I think that for your scenario it will be most suitable to use RadNumericUpDown. In this control you are allowed to enter numeric values only by default. You can easily remove the spin buttons by setting ShowButtons="False". You can validate the Value and write some custom code to return the focus to the control. The ValueChanged event is triggered when the control loses focus by default, so you will get the desired behavior. Note that if you don't remove the spin buttons they trigger the event also. I have attached a sample project illustrating how it can be done.

    Let me know if you have further questions.

    All the best,
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. DevCraft R3 2016 release webinar banner
  4. James
    James avatar
    2 posts
    Member since:
    Dec 2010

    Posted 09 Dec 2010 Link to this post


    Thanks very much for creating the sample project. If I enter an invalid value, it does indeed prevent me from changing the focus using either the mouse or the keyboard. However I noticed that if I first click on another application, then I can return to this application and click on another textbox in the form, thus changing the focus. Any ideas?
  5. Pana
    Pana avatar
    748 posts

    Posted 15 Dec 2010 Link to this post

    Hi James,

    We would not recommend you to lock the focus in the invalidated control.

    Usually in such scenario you would have a view model with several properties and a command or two, a view that has controls bound to the view model and the view model would set the can execute of the commands to false if the data is incorrect. The view would display red marks around the incorrect input but would not lock the user in the wrong control. And the buttons triggering the command would usually go disabled. That's pretty much the recommended way to handle validation.

    Locking the focus results in bad user experience as one can not click "Cancel", can not fill other fields and go back to correct the wrong input etc. I am sure that you would hardly find an MS Office application that behaves the way you describe and even if you do it sure stress the user a lot.

    Note also that the focus feature is part of the framework. We can not do much about it. You can try to lock the focus to the selected control but anything you do in that direction would be hacky.

    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
Back to Top