WPF 触发 VS Converter [英] WPF triggers VS Converter

查看:20
本文介绍了WPF 触发 VS Converter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪个更好地使用性能?与触发器相比,转换器的局限性,反之亦然.我是否应该限制使用转换器,因为它会导致类爆炸?

解决方案

如果您从事 TDD 开发,那么使用转换器将是更好的选择.

如果没有要应用的复杂业务逻辑或自定义逻辑,则选择触发器.关于转换器的另一件事是,根据 Laurent Bugnion(MVVM Light 的创建者)的说法,使用转换器会导致性能下降.

您可以从这篇博文中看到有关性能影响的更多见解.DataTrigger vs 数据绑定与转换器性能明智

您还可以从这篇文章中获取有关何时使用触发器以及何时使用转换器的更多详细信息.我应该使用WPF转换器还是触发器?>

可以根据您正在遵循或将要遵循的开发方法做出决定.大多数时候,我更喜欢将您的视图模型包装在WPF 视图模型"概念中.

Which is better to use performance wise? Limitation of Converter compared to trigger and vice verse. Shall I limit use of converter because it can cause class explosion?

解决方案

If you are into TDD development, it will be better choice to go with converters.

If there is no complex business logic or custom logic to be applied then go for Triggers. One more thing about the converters is that, there is a performance hit associated with using converters according to Laurent Bugnion (creator of MVVM Light).

You can see more insight on the performance hit from this post. DataTrigger vs databinding with converter performance wise

You can get more details on when to you use trigger and when to use converters from this post as well. Should I use WPF converter or trigger?

The decision can be taken based on the development approach you are following or going to follow. I prefer wrapping your view-model in a "WPF Viewmodel" concept most of the time.

这篇关于WPF 触发 VS Converter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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