ribbon ui powershell

Jul 30, 2009 at 7:55 AM
Edited Jul 30, 2009 at 8:54 AM

I am trying to add an action to a ribbon button to a wpf ui through powershell:

This is the example i'm using to implement the ui: http://www.uxpassion.com/2008/11/how-to-use-add-ribbon-to-wpf-applications-part-3/


		<ResourceDictionary Source="C:\test\core\WhistlerBlue\Theme.xaml"/>
		<ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/>
	  <r:RibbonCommand x:Key="ExitGroupCommand" LabelTitle=""/>
	  <r:RibbonCommand x:Key="ExitCommand" Executed="OnRibbonClick" LabelTitle="Exit" LargeImageSource="C:\test\core\icons\application-exit.png" ToolTipDescription="Quit program." ToolTipTitle="Exit (Alt+F4)" />


<r:RibbonGroup Name="ExitProgram" Command="{StaticResource ExitGroupCommand}">
	<r:RibbonButton Command="{StaticResource ExitCommand}"/>


When i try to load the xaml, i get this error


Exception calling "Load" with "1" argument(s): "Must compile XAML file that specifies events. Line '0' Position '0'."
At C:\Users\wasabi\Desktop\metastream\core\gui.ps1:5 char:40
+ $Form=[Windows.Markup.XamlReader]::Load <<<< ( $reader )
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

I need to handle event for ribbon button click. But I can't even load the xaml at all. Can someone help me out with this dilemma?


Jul 31, 2009 at 12:14 AM

I think you can create the 

<r:RibbonCommand x:Key="ExitGroupCommand" LabelTitle=""/>

But not specify the event handler. That is, you have to leave out the: Executed="OnRibbonClick" to get it to work in the Load(...) methods. You can FIND the resource later and attach the handlers in code ...