Search code examples
c#wpfidataerrorinfovalidation

Display IDataErrorInfo Error in Textblock instead of Tooltip


I've seen lots of examples of how to display an error in a tooltip of a textbox. Can someone give me an example of how to display an error in a separate TextBlock instead of in a tooltip of the TextBox?

I'm particularly interested in knowing how to do this if the textbox and textblock are in different views. The view with the textblock has access to the data that has IDataErrorInfo implemented on it though.


Solution

  • So what I ended up doing is adding a property that I set with the Error text. Anytime my Name property is updated, if it has an error, I update the NameError property. I was then able to bind to that property. It seems a little dirty but it did the trick for me.