DelegateCommand only works the second time

Topics: Prism v2 - WPF 3.5
Jun 8, 2009 at 1:22 PM

I have a problem with my delegate Commands.
I have got a MainViewModel and a DialogViewModel. In the DialogViewModel I defined a Command, which gets executed when a dialog should be shown. I make this command as global command, by defining a static CompositeCommand and registering the DelegateCommand.

When I start the application I have a datagrid. Everytime the selectedObjects in this grid are changing I am calling the RaiseCanExecuteChanged-method. This is working properly.
Ok not perfectly, because the first object in the grid I select will not give me the expected behaviour! It will always give me a null value as parameter, although the RaiseCanExecuteChanged-method is called after I set my SelectedEntities-Property and my Command is bound to this property. When I click a second object everything is like expected.

I am not sure why this is happening. I am calling the RaiseCanExecuteChanged-method to ensure, that the databinding is correct at the time. Before I did that the CanExecute-Method was only called once at the beginning and never again.

Has anybody a suggestion?