# HG changeset patch # User Steven Hollidge # Date 1335081680 -3600 # Node ID 810116cd6b8e8f358139f5811c7b968132406db8 # Parent 9de81c9ad319d60461d91ab2701354b82ac70e67 ErrorWindow working diff -r 9de81c9ad319 -r 810116cd6b8e SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml --- a/SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml Sat Apr 21 21:20:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ - - - - - - - diff -r 9de81c9ad319 -r 810116cd6b8e SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml.cs --- a/SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml.cs Sat Apr 21 21:20:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -using System.Reflection; -using System.Windows.Data; -using SilverlightGlimpse.Models; -using System.Windows; -using System.Diagnostics; -using System.Windows.Media; -using SilverlightGlimpse.Services; - -namespace SilverlightGlimpse.Controls -{ - public partial class BrokenBindingsViewer - { - public BrokenBindingsViewer() - { - InitializeComponent(); - } - - private void BrokenBindings_Loaded(object sender, RoutedEventArgs e) - { - this.icBrokenBindings.Items.Clear(); - LoadBrokenBindings(GlimpseService.CreateInstance.RootVisual); - } - - private void LoadBrokenBindings(UIElement uiElement) - { - var frameworkElement = uiElement as FrameworkElement; - - if (frameworkElement != null) - { - foreach (var fieldInfo in frameworkElement.GetType().GetFields(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Static)) - { - if (object.ReferenceEquals(fieldInfo.FieldType, typeof(DependencyProperty))) - { - var bindingExpression = frameworkElement.GetBindingExpression((DependencyProperty)fieldInfo.GetValue(null)); - - if (bindingExpression != null && bindingExpression.ParentBinding.Source == null && bindingExpression.ParentBinding.RelativeSource == null) - { - var isInherited = false; - - if (frameworkElement.DataContext != null && !string.IsNullOrEmpty(bindingExpression.ParentBinding.Path.Path)) - { - foreach (var propertyInfo in frameworkElement.DataContext.GetType().GetProperties(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Instance)) - { - if (string.Compare(propertyInfo.Name, bindingExpression.ParentBinding.Path.Path) == 0) - { - isInherited = true; - break; // TODO: might not be correct. Was : Exit For - } - } - } - - if (isInherited) - { - break; // TODO: might not be correct. Was : Exit For - } - - //this code handles empty bindings on the Button controls - //I'll have to look into why the Button has an empty or unresolved binding - if (string.IsNullOrEmpty(frameworkElement.Name) - && frameworkElement.GetType().Name == "TextBlock" - && fieldInfo.Name == "TextProperty" - && string.IsNullOrEmpty(bindingExpression.ParentBinding.Path.Path)) - { - break; // TODO: might not be correct. Was : Exit For - } - - BrokenBinding objBrokenBinding = new BrokenBinding( - frameworkElement.Name, - frameworkElement.GetType().Name, - fieldInfo.Name, - bindingExpression.ParentBinding.Path.Path); - this.icBrokenBindings.Items.Add(objBrokenBinding); - Debug.WriteLine("Broken Binding - ", objBrokenBinding.ToString()); - } - } - } - - int children = VisualTreeHelper.GetChildrenCount(frameworkElement); - - for (int j = 0; j <= children - 1; j++) - { - FrameworkElement child = VisualTreeHelper.GetChild(frameworkElement, j) as FrameworkElement; - - if (child != null) - { - LoadBrokenBindings(child); - } - } - } - } - } -} \ No newline at end of file diff -r 9de81c9ad319 -r 810116cd6b8e SilverlightGlimpse/Controls/ExceptionsViewer.xaml --- a/SilverlightGlimpse/Controls/ExceptionsViewer.xaml Sat Apr 21 21:20:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -