RibbonSplitButton, RibbonDropDownButton - items become disabled when assigned at runtime?

Dec 30, 2008 at 3:31 PM
Hello,

I've been trying out the Ribbon library (great work btw!). One of the common scenarios in my application is to load items for the RibbonSplitButton or RibbonDropDownButton at init in the context of a specific user. I've tried to add items using code behind just to see if it will work but they always become disabled. Am I missing something obvious?

RibbonCommand

 

testCommand = new RibbonCommand()

 

{

LabelTitle =

"...",

 

LabelDescription =

"...",

 

ToolTipTitle =

"...",

 

ToolTipDescription =

"..."

 

};

 

RibbonMenuItem testMenuItem = new RibbonMenuItem()

 

{

Command = testCommand

};

testSplitButton.Items.Add(testMenuItem);
-----------------------------------------------------------


Kind regards,
Bart

Dec 30, 2008 at 4:58 PM
Hi Bart,

I think you need to add a CommandBinding for your command.  Here is an example:

CommandBinding

 

commandBinding = new CommandBinding(testCommand);

 

commandBinding.Executed +=

new ExecutedRoutedEventHandler(commandBinding_Executed);

 

 

this.CommandBindings.Add(commandBinding);


 

// Event handler

 

 

 

 

private void commandBinding_Executed(object sender, ExecutedRoutedEventArgs e)

 

{

}

Hope this helps,
Alex

Dec 30, 2008 at 5:36 PM
Great! It does work! Thank you Alex!

Kind regards,
Bart