I would like a simple way to ensure that all bindings I’ve declared in my xaml files go to real properties. Even better, I’d like to instantiate my wpf window in a unit test and call a method to ensure that the bindings are correct.
Unfortunately, wpf doesn’t even throw an exception if I have something wrong. That leaves me the burden to ‘discover’ problems during a QA phase.
Does anyone know of a way I can better validate my bindings?
A suboptimal way would be to search through the visual tree for all dependency properties, and then check:
If the
statusisUnattachedthen the expression hasn’t resolved.Of course, you wouldn’t want to do this in a production app, but it might make sense in a debug or integration test scenario.