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

  • Home
  • SEARCH
  • 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 651283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:08:45+00:00 2026-05-13T22:08:45+00:00

I’ve got a button that I need to be disabled when validation errors occur

  • 0

I’ve got a button that I need to be disabled when validation errors occur in my window. The items on which these errors can occur are all textboxes.

I’ve bound my Button’s datacontext as such:

DataContext="{Binding ElementName=txtEmail}"

Now with this, I can set the button style to disabled when validation errors occur in the email textbox, but I want to do it also when it occurs in other textboxes in my window?

How can I set this binding to multiple textboxes?

  • 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-13T22:08:45+00:00Added an answer on May 13, 2026 at 10:08 pm

    You can’t, at least not directly. You could use a MultiBinding with all of the desired text boxes as inputs, but you will need to provide an IMultiValueConverter to “combine” the various text boxes into one object (such as a list):

    <Button>
      <Button.DataContext>
        <MultiBinding Converter="{StaticResource ListMaker}">
          <Binding ElementName="txtEmail" />
          <Binding ElementName="txtFirstName" />
          <Binding ElementName="txtLastName" />
        </MultiBinding>
      </Button.DataContext>
    </Button>
    

    And it is then that resulting list object that will be passed to your trigger, so you won’t be able to access the Validation.HasError property directly: your DataTrigger will also need to bring in a converter which converts the list object into a boolean indicating whether Validation.HasError is set for anything in the list. At this point you might as well just forget about triggers and bind IsEnabled using a MultiBinding:

    <Button>
      <Button.IsEnabled>
        <MultiBinding Converter="{StaticResource AllFalse}">
          <Binding Path="(Validation.HasError)" ElementName="txtEmail" />
          <Binding Path="(Validation.HasError)" ElementName="txtFirstName" />
          <Binding Path="(Validation.HasError)" ElementName="txtLastName" />
        </MultiBinding>
      </Button.DataContext>
    </Button>
    

    (Here the AllFalse converter returns true if all inputs are false, and false if any input is true.)

    A better approach, however, may be, instead of binding the Button directly to other UI elements, have your data object — the same object that your text boxes are binding to — expose an IsValid property (with suitable change notifications), and bind your Button.IsEnabled to that:

    <Button IsEnabled="{Binding IsValid}" />
    

    This moves you towards a MVVM-style solution which helps with things like testability (e.g. it’s easy to create tests for the IsValid property; it’s much harder to create tests for Button.IsEnabled).

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

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.