WPF转换器如何执行? [英] How WPF Converters are executed?

查看:131
本文介绍了WPF转换器如何执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在面对非常复杂的WPF UI中的渲染问题,其中包含许多转换器(IValueConverter,IMultiValueConverter)。

I'm facing render issues in very complex WPF UI which contains, among other things, a lot of Converters (IValueConverter, IMultiValueConverter).

我想知道转换器是否可以参与到这个。

I would like to know if the converters could be involved into this.

有谁知道WPF转换器如何工作?
它们是否并行执行,然后与UI线程同步?或者是否有某种foreach循环来处理每个转换器?

Does anyone known how WPF Converters worked ? Are they executed in parallel and then synchronized with the UI thread ? or is there some kind of foreach loop that treat every converter ?

推荐答案

转换器在UI线程上执行,您可以通过使用类似 Thread.Sleep(10000)的线程阻止线程来测试。 UI在调度程序队列中进行管理,有关更多信息,请参阅线程模型参考,更新绑定被推入该队列。转换器被调用,如果绑定更新,它们通常不会同时被调用。

The converters are executed on the UI-thread, you can test this by blocking the thread using something like Thread.Sleep(10000). The UI is managed in a dispatcher queue, see the threading model reference for more information, updates to bindings are pushed into that queue. Converters are called if the binding was updated, they normally are not being called at the same time.

(另见下面的好评论)

这篇关于WPF转换器如何执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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