Ribbon - Prism - OpenFile Command

Ribbon for WPF Forum

Posted 6 years ago by Stephane Franiatte
Version: 14.2.0610
Avatar

Hi,

I am currently testing the Ribbon, although this is not a question directly related to this control. I have a DelegateCommand, OpenFileCommand, which can take a String (the file path), but not necessarly (the same command is used to open the Open File Dialog, in case the String is Null). I get the following error, at runtime:

Unable to cast object of type 'ActiproSoftware.Windows.Controls.Ribbon.Input.CheckableCommandParameter' to type 'System.String'

Here is a workaround I found:

<!--Open Button-->
                <ribbon:Button Label="Open" 
                               ImageSourceSmall="/MyApp;component/Images\Open.ico"  
                               KeyTipAccessText="O" 
                               Command="{x:Static module:ModuleCommands.OpenFileCommand}"
                               CommandParameter=" "/>

 And in my function, I use IsNullOrWhiteSpace to trigger the opening of the Open File Dialog.

However, I would like to avoid doing this, I am sure there is a way to handle DelegateCommand(Of String) properly?

Thanks

[Modified 6 years ago]

Comments (4)

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

Hi Stephane,

The ribbon:Button control has a CheckableCommandParameter instance in CommandParameter by default.  By specifying a value as you do there, you force it to a string instead.  You might also be able to set it to "{x:Null}" instead of " ".  That's the only other suggestion I'd have.


Actipro Software Support

Posted 6 years ago by Stephane Franiatte
Avatar

Hi,

yeah, that's what I thought. That is not a really big deal anyway; I am more concerned about my other problem (see my other post).

Thanks!

Posted 5 months ago by eric
Avatar

Well we are facing a similar issue here after we've upgraded to 2019.

In our case we need to move the parameter so that it is defined before the Command like so:

<ribbon:Button
Label="Blabla"
CommandParameter="{Binding MyParam}"
Command="{Binding MyCommand}"/>
 
instead of
<ribbon:Button
Label="Blabla"
Command="{Binding MyCommand}"
CommandParameter="{Binding MyParam}"
/>
 
to us this is a bug in actipro and we now need to fix this in over 20-30applications.
 
A fix would be appreciated.
 
Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

Since this is an old thread, can you please write us at our support email address?  In the e-mail, please describe the exact problem in detail, and which version/build you were using before, and which version/build you are using now.  Then we can discuss what might have changed and continue the discussion further.  Thanks!


Actipro Software Support

The latest build of this product (v2020.1.0) was released 17 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.