【发布时间】:2010-10-20 16:17:53
【问题描述】:
我现在正在尝试维护其他人的代码,该人是 WPF 专家。另一方面,我不是。 :)
代码使用 IValueConverter 将状态枚举转换为布尔值,该布尔值控制 UserControl 是否显示在屏幕上。
我发现了一个缺点,在这种情况下单个枚举是不够的,实际上还需要考虑另一个布尔值。是否有另一个可以使用的对象将 2 个项目作为参数来进行转换? (“转换器”参数已被使用。)
下面是一个简单的例子。
现有代码的逻辑说...
If it's sunny, go to work.
If it's raining, don't go to work.
我需要考虑另一件事,它会如下所示。
If it's sunny and you're wearing pants, go to work.
If it's sunny and you're not wearing pants, don't go to work.
If it's raining and you're wearing pants, don't go to work.
If it's raining and you're not wearing pants, don't go to work.
IValueConverter,它将执行转换只允许我拿一个“东西”进行转换。
感谢任何帮助。谢谢,
mj
【问题讨论】:
标签: c# .net wpf ivalueconverter