Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

WPF Validation Errors: Find the Missing Message and Choose the Right Interface

WPF may record a validation error without displaying its explanation. Check the binding state, validation option, update timing, and error template, then choose the interface that fits your validation model.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

WPF can record a validation error without showing its explanation as readable text. First check whether the binding has set Validation.HasError and populated Validation.Errors; if it has, investigate the control’s error presentation rather than the validation rule. Then confirm that the binding is using the right validation interface and option.

Why can WPF have an error but not show its message?

Validation and presentation are separate parts of WPF data binding. A binding rule or source can produce an error; WPF records errors for the bound element in Validation.Errors and sets Validation.HasError when an error is present. The default ErrorTemplate indicates an error with a red border in the adorner layer, but that visual cue does not necessarily display the explanatory message. Microsoft’s WPF binding overview describes the validation state and default template, while an archived Microsoft article notes that the error message is not displayed by default. Microsoft: Data binding overview – WPF; Microsoft: Input Validation – Enforcing Complex Business Data Rules with WPF.

As an Amazon Associate I earn from qualifying purchases.

That distinction is the fastest way to narrow the problem: if the control has no validation error, check the binding, source, and validation configuration. If it does have one, check how the control or application presents it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to diagnose a missing WPF validation error

  1. Verify the binding source and property. Check that the control’s effective DataContext (or its explicit binding Source) is the object implementing the intended interface, and that the binding Path names the property being validated. A mismatch means WPF may be asking a different object or property than you expect.
  2. Check the validation option for the interface in use. For IDataErrorInfo, enable ValidatesOnDataErrors="True" or include a DataErrorValidationRule. For INotifyDataErrorInfo, check ValidatesOnNotifyDataErrors; its documented default is true, but a binding can disable it. See Microsoft’s API references for ValidatesOnDataErrors and ValidatesOnNotifyDataErrors.
  3. For IDataErrorInfo, inspect the indexer result. WPF’s ordinary property validation asks the interface indexer for the bound property’s error. Confirm it returns a nonempty message for the property name; the interface’s Error property is not what the binding engine uses for that property-level check. Microsoft’s interface guidance describes the indexer and Error contract: IDataErrorInfo Interface.
  4. Inspect the control’s validation state. Check Validation.HasError and Validation.Errors on the bound control. If they indicate an error, WPF has recorded one and the remaining issue is likely presentation. A later valid source transfer can clear the error state. Microsoft’s binding overview documents these attached properties and the validation lifecycle.
  5. Inspect the template, style, and tooltip. A style or custom ErrorTemplate may replace or obscure the default visual cue. If the user needs the actual explanation, provide a tooltip or another accessible message treatment that reads the error content. Microsoft’s ValidatesOnDataErrors example demonstrates binding a tooltip to the first error’s ErrorContent.
  6. Check event and update timing. The attached Validation.Error event is raised only for bindings with NotifyOnValidationError="True". Also check UpdateSourceTrigger: validation commonly runs when the target value transfers to the source, so a rule that runs on source update may not appear to fire until that transfer happens. Microsoft: Data binding overview – WPF.

Example: show the first error in a tooltip

This illustrative pattern follows Microsoft’s documented tooltip approach for IDataErrorInfo; it is not a diagnosis or tested fix for a particular application.

<TextBox>
  <TextBox.Style>
    <Style TargetType="TextBox">
      <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="True">
          <Setter Property="ToolTip"
                  Value="{Binding RelativeSource={RelativeSource Self},
                                  Path=(Validation.Errors)[0].ErrorContent}" />
        </Trigger>
      </Style.Triggers>
    </Style>
  </TextBox.Style>
  <TextBox.Text>
    <Binding Path="Name"
             ValidatesOnDataErrors="True"
             UpdateSourceTrigger="PropertyChanged" />
  </TextBox.Text>
</TextBox>

The sample uses PropertyChanged to illustrate one update timing choice. Choose an UpdateSourceTrigger that matches the desired validation behavior; changing it does not by itself add a visible message.

Should you use IDataErrorInfo or INotifyDataErrorInfo?

Choose based on the source object’s validation contract and the application’s needs, not on which interface makes errors visible: neither one alone guarantees that explanatory text appears in the UI.

Decision IDataErrorInfo INotifyDataErrorInfo
Binding activation Set ValidatesOnDataErrors="True" or use a DataErrorValidationRule. Microsoft API reference. ValidatesOnNotifyDataErrors defaults to true in the documented WPF API; it can be explicitly set on the binding. Microsoft API reference.
Where property errors come from The indexer supplies the bound property’s error. The binding engine does not use Error for an ordinary bound-property check. Microsoft interface guidance. When enabled, WPF checks for and reports errors from a source implementing the interface. Verify that the implementation exposes the expected errors and notifications. Microsoft API reference.
When it fits A straightforward synchronous property-validation pattern. Microsoft’s interface guidance says new entity classes should generally prefer INotifyDataErrorInfo for added flexibility and identifies future asynchronous validation as a limitation of IDataErrorInfo. Microsoft interface guidance. A notification-based model where the added flexibility is useful. Do not assume that an interface alone guarantees a particular asynchronous-validation behavior; check the target framework and validation implementation. Microsoft API reference.
How errors become visible Neither interface supplies a complete user-facing display by itself. Check the WPF validation state and configure an appropriate tooltip, template, or other presentation. Microsoft binding overview.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What framework compatibility should you check?

Do not infer compatibility from the interface name alone. Microsoft’s API pages list ValidatesOnDataErrors across .NET Framework and Windows Desktop versions, and list ValidatesOnNotifyDataErrors for .NET Framework 4.5 onward and Windows Desktop 3.0 onward. Confirm the application’s target runtime and the controls or libraries it uses against the relevant API documentation before relying on version-specific behavior: ValidatesOnDataErrors applicability and ValidatesOnNotifyDataErrors applicability.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.