Setting CommandParameter to null

Ribbon for WPF Forum

Posted 15 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Version: 4.5.0485
Avatar
I have a SplitButton with a Menu containing several normal Buttons as PopupContent. Each Button in the menu is meant to execute the same command with a different parameter, and the SplitButton is meant to execute the same command as an 'All' option. I am trying to detect the 'All' option in my command handler by setting the CommandParameter to {x:Null}, but it still seems to be passed through as a CheckableCommandParameter.

This isn't too big a deal as I can simply do a type check in my handler instead of checking for null, but I was wondering if this was the intended behavior?

Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Phil,

If you can put together a simple sample project that shows this and email it over to our support address, we'd be happy to debug it and figure out what is happening. Thanks!


Actipro Software Support

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Phil,

Thanks for the sample. I see what is doing it now.

Basically we wanted to have controls like SplitButton default to using a CheckableCommandParameter. However if you set it in a Style, a single instance of CheckableCommandParameter is used by all SplitButton instances. This of course is bad since each one should have their own instance.

So what we did was have a coersion on the property where if it is null, we use an instance-specific default command parameter. So you are seeing the coersion take place.

If you assign anything other than null, it will use what you assign. I'd recommend sticking with your type check due to this scenario.


Actipro Software Support

Posted 15 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Avatar
Thanks, I thought it would be something like that but wanted to make sure
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.