WPF 中的类型转换器 [英] Type Converter in WPF
本文介绍了WPF 中的类型转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读了这篇文章,但我对 Type Converter 及其用法仍然不是很清楚.
I have gone through this article but still i am not very much clear about Type Converter and its usage.
http://msdn.microsoft.com/en-us/library/aa970913.aspx
谁能解释一下它是什么以及在 WPF 中可以用它做什么.
Can anyone please explain in what it is and what can be done with it in WPF.
推荐答案
例如 - 当你在 XAML 中设置背景属性时,你可以写Red",在你后面的代码中不能只给背景属性字符串Red"" 因为它的类型是 Brush.WPF 使用类型转换器将字符串转换为画笔.
For example - when you set a background property in XAML, you can write "Red", in code behind you cannnot just give the Background property the string "Red" because its type is Brush. WPF uses a type converter to convert from string to brush.
这篇关于WPF 中的类型转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文