我现在正在尝试维护其他人的代码,该人是 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 只允许我拿一个“东西”进行转换。
任何帮助表示赞赏。谢谢,
米