为什么 WPF 数据绑定会吞下异常? [英] Why does WPF databinding swallow exceptions?

查看:22
本文介绍了为什么 WPF 数据绑定会吞下异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近浪费了很多时间尝试调试 WPF 数据网格(来自 WPF 工具包).我有一个绑定到 linq 查询的列,其属性抛出异常(在几行中).WPF 似乎捕捉到异常,它只是使单元格空白.我已经修复了导致异常的错误,但我想更改 WPF 的行为.我总是想知道是否有问题.为什么吞下异常是默认行为,我该如何改变它?

I recently wasted a lot of time trying to debug a WPF datagrid (from the WPF Toolkit). I had a column bound to a linq query with a property that was throwing an exception (in a few rows). WPF seems to catch the exception and it just makes the cells blank. I have fixed the bug causing the exception, but I would like to change WPF's behavior. I always want to know if something is wrong. Why is swallowing the exception the default behavior and how can I change it?

推荐答案

数据绑定错误在本机被吞并,但它们显示在 Visual Studio 界面的 OUTPUT 对话框中.如果您希望收到通知(并尽可能多地控制它),那么您可以使用 Trace Sources.

Databinding errors are swallowed natively, but they are displayed in the OUTPUT dialog in the visual studio interface. If you wish to be notified (and have as much control over it as possible), then you can use Trace Sources.

Bea Stollnitz 在此处提供了关于此(以及调试一般绑定)的精彩文章:http://www.beacosta.com/blog/?p=52

Bea Stollnitz provides a great writeup about this (and debuginng the bindings in general) here: http://www.beacosta.com/blog/?p=52

显然,此博客已离开,但我们确实有 WayBack Machine:http://web.archive.org/web/20091103200557/http://www.beacosta.com/blog/?p=52

Apparently, this blog has departed, but we do have the WayBack Machine: http://web.archive.org/web/20091103200557/http://www.beacosta.com/blog/?p=52

我还将它添加到我的 Evernote 编码笔记本中:https://www.evernote.com/pub/view/sswrighton/coding/f9786746-94c3-41b5-bcd2-c12992d331a6?locale=en#st=p&n=46794c3-41b5-bcd2-c12992d331a6

I also added it to my Coding notebook for Evernote: https://www.evernote.com/pub/view/sswrighton/coding/f9786746-94c3-41b5-bcd2-c12992d331a6?locale=en#st=p&n=f9786746-94c3-41b5-bcd2-c12992d331a6

这篇关于为什么 WPF 数据绑定会吞下异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆