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/

 

<Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="C:\test\core\WhistlerBlue\Theme.xaml"/> <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/>
 </ResourceDictionary.MergedDictionaries> <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)" /> </ResourceDictionary> </Window.Resources> ... <r:RibbonGroup Name="ExitProgram" Command="{StaticResource ExitGroupCommand}"> <r:RibbonButton Command="{StaticResource ExitCommand}"/> </r:RibbonGroup> 

 

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:\test\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. How do I add event handling when I can't load the xaml? I can't add the event before the xaml is loaded because it doesn't exist yet.