Here I will post problems I and my colleagues met and solutions we found.

Thursday, March 24, 2011

The order in Xaml is important

Today I had one more chance to notice that the order in XAML is important.What I had was a button with code like this:



<Setter Property="Command" Value="{Binding Command}" />
<Setter Property="CommandParameter" Value="{Binding CommandParameter}"/>

Notice that I assigned Command before CommandParameter. When I was doing it, I din't even think about it. I just added support for CommandParameter at some point so I naturally added this line at the end. However, CanExecute method from ICommand was triggered immediatelly after Command was assigned to the control, even before CommandParameter was assigned. Obviously, it didn't work.

When I changed the order, it's all started to work.

No comments: