views:

59

answers:

1

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

A: 

If you are comparing delegates, it's likely that, especially if you use lambdas or anonymous delegates, that their RuntimeTypes are different.

My suggestion would be that you override the Equals method for these types manually on each type. You are likely taking a performance hit in doing these reflection-based comparisons and you are always going to run into these little nitpicky problems.

I know it feels like something you should be able to solve once and forever, but this doesn't seem likely. I hope this doesn't let the wind out of your sails too much.

Anderson Imes