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 6030523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:02:56+00:00 2026-05-23T05:02:56+00:00

I have a datagrid with a template column, and in that template is a

  • 0

I have a datagrid with a template column, and in that template is a textbox. It’s bound to the ‘Quantity’ property of the object in the collection that makes up itemssource. Quantity is an integer. When I add an item to the datagrid, I am adding an event handler to the PropertyChanged event of the item:

EnteredPart.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(p_PropertyChanged);

This works fine when the user enters an integer in the textbox… the p_PropertyChanged handler fires and I can disable buttons and alter quantities as necessary. When the user enters a non-integer, the handler doesn’t get called, I just get a red outline around the textbox. Because of this, I can’t disable the necessary buttons when I need to (they should be disabled with the quantity is not legit.) Is there any way that I can do something about this?

EDIT: I tried changing the Quantity property to a string, and this caused the property changed handler to be called when non-integral values are entered. However, I then added validation to the textbox to check for this, and if the Validate method returns false, the property changed handler once again ceases to be hit. Is there any way at all to get both validation and property changed notifications??

EDIT 2: Here another instance of this problem I’m having, in another location. I have a form for adding/editing phone numbers. The phone number textbox looks like this:

  <TextBox >
       <TextBox.Text>
           <Binding Path="Phone.Number">
               <Binding.ValidationRules>
                   <local:PhoneValidationRule />
               </Binding.ValidationRules>
           </Binding>
       </TextBox.Text>
   </TextBox>

Upon clicking a save button, I need to check in my viewmodel if the number is valid, because if it’s not, I don’t want to run the save command. However, it doesn’t seem as if there’s any way to do that, because if the validation fails, then the Phone.Number property has a null value, and I have no way to check to see if I should run the save command. I either need access to the error state (which I thought would work by Validation.GetErrors, but doesn’t), or to the actual text within the textbox, which isn’t available in the viewmodel.

  • 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-05-23T05:02:57+00:00Added an answer on May 23, 2026 at 5:02 am

    Just for the record, validation in the View part has many drawbacks if you are in an MVVM architecture.

    You’d try here to check your model’s content, in the view: you’d therefore break MVVM’s architecture by calling your model in the view.

    Using IDataErrorInfo will help you to fulfill MVVM’s main objective (ie. clearly separate the three parts).

    Just an example:

    I think here you are just performing a very small validation (just check if it is an int or not).
    But in a different environment, assume that your model is much more complicated and needs a deeper validation. Using IDataErrorInfo will help you to check deeply in your model without calling it from the view.
    As a matter of fact, in my personal experience, as I regularly work with large and highly correlated datasets, I cannot even picture using validation without IDataErrorInfo because it’d cost me too much to investigate in all the data presented and find potential errors

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

Sidebar

Related Questions

I have a datagrid that's bound to an observablecollection object. The collection may be
I have a Silverlight DataGrid that contains a single template column which displays a
I have a datagrid and a template column which is bound. I don't understand
Here's my problem: I have a datagrid that is bound to a collection of
I have a DataGrid with 5 template columns, However when I try and add
I have a Silverlight 4 DataGrid which has its ItemsSource bound to an ObservableCollection
I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
I do have a page that has a TextBox a Button and a Datagrid.
I have implemented a DataGrid that way: <DataGrid x:Name=MyDataGridFilter ItemsSource={Binding} IsSynchronizedWithCurrentItem=True AutoGenerateColumns=False> <DataGrid.Columns> <DataGridTemplateColumn
I have a read-only datagrid bound to a domain data source. The data that

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.