WPF UserControl with Ribbon Control from RibbonControlLibrary in CAB application problem - pls help!!!

Feb 4, 2009 at 4:55 PM
I have simple "System.Windows.Controls.UserControl" based text editor, with Ribbon menu. When I use this control hosted in CAB application pane, all the Ribbon controls, using RibbonCommand are DISABLED :-(
I have two RibbonComboBoxes there, which doesn't use RibbonCommands and theese are enabled and working well. But all RibbonButtons, menus etc. are gray and I have no chance to enable it...
"CanExecute" events are not called in the control at all....Only one RibbonCommand event is fired and it is "PropertyChanged". All others event are sleeping. Any idea how to manage it? Thanks a lot...
Feb 4, 2009 at 5:46 PM
This sounds like it might be a Focus issue.  You can try some of the solutions presented in this thread and see if they work for you: http://www.codeplex.com/wpf/Thread/View.aspx?ThreadId=40319.  (Set FocusManager.IsFocusScope to true or call Focus() directly whenever the menu items are getting grayed out.)

Feb 4, 2009 at 6:45 PM
Hallo Samantha,
I tried it, but without success :-( 
You can see printscreen there:
I looks like CAB is eating Command activity anywhere... As any way how to manage RibbonCommand and enable it? Thanks for your help..
BTW: when I use UserControl in simple WPF window, it works fine (you can see it there:   )
Feb 4, 2009 at 6:55 PM
Just for detailed information - I'm not able to get RibbonButtons enabled, however I'm clicking by mouse on the application everywhere...
Feb 4, 2009 at 8:51 PM
Edited Feb 4, 2009 at 8:52 PM
If I use the control in CAB application, it is not enough have this in XAML definition:



r:RibbonCommand x:Key="SaveDocCommand" Executed="SaveDocCommandExecuted" SmallImageSource="Resources\floppy.png"  LargeImageSource="Resources\floppy.png" ToolTipTitle="Save" ToolTipDescription="Save document on disk" />






This solution works in simple application. As I wrote above, if I host such control in CAB application, all command-bind controls (RibbonButtons etc) are disabled and commands has no events...
I don't knouw exactly why, but if I add in "after-load" control code explicit command binding - such like this:



.CommandBindings.Add(new CommandBinding(this.m_rbbtSaveDoc.Command, SaveDocCommandExecuted));

Ribbon works fain again!!! Thank you Samantha for your effort.

Mar 3, 2009 at 12:35 PM
i also had the same problem but i some how resolved why i made static fields out of my commands (not static properties)

public static RibbonCommand Doit = new RibbonCommand { LabelTitle = "doit", ToolTipTitle = "doit doit" };

instead of

public static RibbonCommand Doit {
      get { return new RibbonCommand { LabelTitle = "doit", ToolTipTitle = "doit now" }; }

i cant tell you why this works or why some demos dont do it like that and still work :P
on another note, some docs on the ribbon api would be great, right now im pretty much fumbeling in the dark :)