Hi,
We're stuck on an older version (2011.1), but wanted to see if you had any input on this issue. We're using "by the book" MVVM, so we're binding controls to RelayCommandT:
<ribbon:Button ImageSourceSmall="/Demo;component/Resources/Delete16.png" ScreenTipHeader="Delete Server" Focusable="False"
Command="{Binding Path=DeleteCommand}" CommandParameter="{Binding ElementName=lbServers, Path=SelectedIndex}" />
My RelayCommandT is declared as a RelayCommandT<int>. The behavior we're seeing is:
1) CommandParameter = null / unbound - control sends a ICheckableCommandParameter structure in argument
2) CommandParameter hardcoded (i.e. "2", "xyz", etc) - control sends "2", "xyz" in argument as expected
3) *ISSUE* CommandParameter is bound as above = command is called ONCE with a ICheckableCommandParameter and SUBSEQUENT times with the correct bound value.
#3 is obviously an issue for RelayCommand<int>() if you are sending "the wrong datatype" one time. I do understand the nature of binding and have run into this issue myself as there is no way to know when "all bindings have been setup" as a control author, is there a work-around? I'm currently working around the issue by creating a RelayCommand<T1, T2> where I can specificy the CanExecute param differently then the ExecuteParam and I specify it as an object and check the type. Seems like the Tag parameter is not used for the ICheckableCommandParameter structure and I have to do something more verbose like:
<ribbon:Button.CommandParameter>
<ribbon:CheckableCommandParameter Tag="1" />
</ribbon:Button.CommandParameter>
Are there any other known workarounds that might be cleaner? These all seem kind of hacky :(.
Thanks!