0

I would like to use an MVVM in a WPF project I'm working on, including the use of RelayCommands (aka DelegateCommands). I'm running into an interesting but frustration problem in implementing equality for my ViewModels, outlined here. I have a base class in my ViewModel hierarchy which examines all properties reflectively as part of its equality comparison, and the Command consistently fails even when it looks like it shouldn't.

How are others of you using this design approach dealing with equality?

Cheers,
Berryl

4

1 回答 1

0

如果您在比较委托,很可能,特别是如果您使用 lambda 或匿名委托,它们的 RuntimeTypes 是不同的。

我的建议是您在每种类型上手动覆盖这些类型的 Equals 方法。在进行这些基于反射的比较时,您可能会受到性能影响,并且您总是会遇到这些小问题。

我知道这感觉像是你应该能够一劳永逸地解决的问题,但这似乎不太可能。我希望这不会让你的风帆太大。

于 2009-10-27T18:47:04.147 回答