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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:14:16+00:00 2026-05-21T12:14:16+00:00

I have around 20 controls which are binded to different properties of a class

  • 0

I have around 20 controls which are binded to different properties of a class along with validation rules like following. For sake of understanding i am writing the code for one control as other are same.

<TextBox  Style="{StaticResource errorStyle}" Grid.Column="0" Grid.Row="2" Grid.RowSpan="1" HorizontalAlignment="Left" Margin="110,100,0,0" Name="balesText" VerticalAlignment="Top" Width="170" >
        <TextBox.Text>
            <Binding Source="{StaticResource insertTransaction}" UpdateSourceTrigger="Explicit" Path="Bales">
                <Binding.ValidationRules>
                    <ExceptionValidationRule/>
                </Binding.ValidationRules>
            </Binding>
        </TextBox.Text>
    </TextBox>

Right now i am checking for the input errors in code-behind in the following manner

BindingExpression balesBe = balesText.GetBindingExpression(TextBox.TextProperty);
balesBe.UpdateSource();
.
.
if (balesBe.HasError)
        {
            MessageBox.Show("Please correct Errors", "Insert Aborted");
        }
        else
        {
            Binding insertTransactionBinding = BindingOperations.GetBinding(balesText, TextBox.TextProperty);
            InsertTransaction insertTransaction = insertTransactionBinding.Source as InsertTransaction;
            insertMessage = insertTransaction.Add();
            MessageBox.Show(insertMessage, "Transaction");
            this.NavigationService.Refresh();
        }

Now, the Question is : Is there any way i can validate these 20 controls in one go or i need to manually define their BindingExpression and check for validation error??

  • 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-21T12:14:16+00:00Added an answer on May 21, 2026 at 12:14 pm

    Make your own UserControl “OwnTextBox”. Inherit it from TextBox (OwnTextBox: TextBox) and define there DependencyProperty Validate. Then you only have to remember, that TextBox is part of logical tree and make search from it.

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

Sidebar

Related Questions

I have a wpf application with some Thumb controls which move items around a
I have list of object which i loop around and create controls from. i
I have a custom UI control which has a JavaScript class written around the
I have a large project in Vb.net which drives a web browser control around.
I would like to have fuzzy looking border around my Canvas control. Basically, I
I have around 1000 processes which should be executed independently. I have 8 cores.
I have around 400 GB Live mysql Databases on one server and I like
I have around 100 rows of text that I want to tokenize, which are
I have this situation which is rather frustrating... I have some user controls where
I am currently experimenting with various input controls and have stumbled upon SneakyInput, which

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.