Last active
August 29, 2015 14:17
-
-
Save nickdarnell/c4ec71d8794191d74fd6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void CheckForBindingErrors(DependencyObject parent) | |
| { | |
| // Examine parent for binding errors | |
| LocalValueEnumerator localValues = parent.GetLocalValueEnumerator(); | |
| while (localValues.MoveNext()) | |
| { | |
| LocalValueEntry entry = localValues.Current; | |
| if (BindingOperations.IsDataBound(parent, entry.Property)) | |
| { | |
| BindingExpression binding = | |
| BindingOperations.GetBindingExpression(parent, entry.Property); | |
| if (binding.DataItem == null) | |
| continue; | |
| if (binding.Status == BindingStatus.PathError) | |
| { | |
| // Found binding error | |
| } | |
| } | |
| } | |
| // Examine children for binding errors | |
| for (int i = 0; i != VisualTreeHelper.GetChildrenCount(parent); ++i) | |
| { | |
| DependencyObject child = VisualTreeHelper.GetChild(parent, i); | |
| CheckForBindingErrors(child); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment