Ribbon - Prism - OpenFile Command

Ribbon for WPF Forum

Posted 5 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 5 years ago]

Comments (2)

Posted 5 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 5 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!

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.