Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8856243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:18:50+00:00 2026-06-14T14:18:50+00:00

I have a textbox that is bound to an Integer property. when the user

  • 0

I have a textbox that is bound to an Integer property. when the user enters something in the textbox that can’t be converted to an integer (eg. name) an exception will be thrown and the original property value won’t change. i want to catch the exception so that i can disable a command that is connected to that property ? how can i do that in general and if possible from the view model where the property is defined ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:18:51+00:00Added an answer on June 14, 2026 at 2:18 pm

    Consider calling the command from the view model instead of from the view.

    private int _myProperty;
    public int MyProperty
    {
        get
        {
            return _myProperty;
        }
        set
        {
            _myProperty = value;
            // See if the value can be parsed to an int.
            int potentialInt;
            if(int.TryParse(_myProperty, out potentialInt))
            {
                // If it can, execute your command with any needed parameters.
                yourCommand.Execute(_possibleParameter)
            }
        }
    }
    

    This will allow you to handle the user typing things that cannot be parsed to an integer,
    and you will only fire the command when what the user typed is an integer.

    (I didn’t test this code, but I think it might be helpful.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TextBox that is bound to my ViewModel. The TextWrapping property of
I have a textbox that is bound to a property that requires a value,
I have a TextBox control on my form that is bound to a property
I have a textbox that is bound to a property on my ViewModel called
I have a TextBox that is bound to a Text-property on an Entity-object. I'd
I have a textbox that i am binding to the viewmodel's string property. The
Hi I have a textbox that takes a username input. When the user submits
For example, I have a textbox that I need to have a Left property
I have a class that is bound to GUI elements as follows: <TextBox Style={StaticResource
I have a TextBox bound to a DateTime using a converter that implements Convert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.