WPF 查看绑定错误——Snoop 的基本使用

关于

可以通过 Snoop 查看 WPF 程序的 Visual Tree,更多介绍请看 snoopwpf

快速开始

一、下载 snoopwpf.msi

安装后打开,选择自己的程序,点击 snoop(望远镜)

WPF 查看绑定错误——Snoop 的基本使用_第1张图片
二、筛选

点击左侧下拉列表,选择 Show only elements with binding errors

WPF 查看绑定错误——Snoop 的基本使用_第2张图片


三、点击出错的节点,右侧点击 Properties,然后滚动表格,找到标红的一行

WPF 查看绑定错误——Snoop 的基本使用_第3张图片

四、右键选择 Display Binding Errors

WPF 查看绑定错误——Snoop 的基本使用_第4张图片

五、分析错误

System.Windows.Data Error: 23 : Cannot convert '' from type '' to type 'System.Double' for 'en-US' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: DoubleConverter 无法从 (null) 转换。
   在 System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   在 System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   在 System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   在 MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 6 : 'ObjectSourceConverter' converter failed to convert value '' (type ''); fallback value will be used, if available. BindingExpression:Path=Tag; DataItem='ProgressBar' (Name=''); target element is 'Rectangle' (Name=''); target property is 'RadiusX' (type 'Double') NotSupportedException:'System.NotSupportedException: DoubleConverter 无法从 (null) 转换。
   在 MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
   在 MS.Internal.Data.ObjectSourceConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
   在 System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'

你可能感兴趣的:(wpf)