Can you add a dropdown or a textbox to the ribbon?
I have version 10.2 and I am unable to get this to work. I can add the item to a XamRibbonGroup, but it does not show up in the editor or at run-time.
public class TextBoxTool : RibbonTool {
protected override RibbonToolBaseControl ResolveToolControl() {
return new TextBoxToolControl(this);
}
public string Text { get; set; }
public class TextBoxToolControl : RibbonToolBaseControl, IRibbonControl {
private TextBox m_Text;
public TextBoxToolControl() {
this.DefaultStyleKey = typeof(TextBoxToolControl);
public TextBoxToolControl(RibbonToolBase tool) : base(tool) {
public override void OnApplyTemplate() {
base.OnApplyTemplate();
this.m_Text = GetTemplateChild("Text") as TextBox;
if (this.m_Text != null) this.m_Text.Text = ((TextBoxTool)this.Tool).Text;
<Style TargetType="local:TextBoxToolControl">
Hi,
Is it possible to create a class that extends XamRibbonTabItem so this item can be added to differnent Ribbon?
Thanks
Note: This will only work after the first service release for 10.1
Ok, here's a quick explanation on how to add a combobox tool to the XamWebRibbon.
First you're going to want to create two new classes, ComboBoxTool and ComboBoxToolControl. The tool is what we'll put into a XamWebRibbonGroup's items collection, the tool then generates the tool control.
public class ComboBoxTool : RibbonTool
{
protected override RibbonToolBaseControl ResolveToolControl()
return new ComboBoxToolControl(this);
public IEnumerable ItemsSource { get; set; }
public class ComboBoxToolControl : RibbonToolBaseControl, IRibbonControl
private ComboBox _combo;
public ComboBoxToolControl()
this.DefaultStyleKey = typeof(ComboBoxToolControl);
public ComboBoxToolControl(RibbonToolBase tool) : base(tool)
this.DefaultStyleKey = typeof (ComboBoxToolControl);
public override void OnApplyTemplate()
this._combo = GetTemplateChild("Combo") as ComboBox;
if (this._combo != null)
this._combo.ItemsSource = ((ComboBoxTool) this.Tool).ItemsSource;
Then you need to define the style for the ComboBoxToolControl in your generic.xaml file:
<Style TargetType="cust:ComboBoxToolControl">
<Setter Property="Foreground" Value="Green"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="cust:ComboBoxToolControl">
<Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch" Background="Transparent">
<Grid >
<ComboBox x:Name="Combo" Width="100" Height="24" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
At this point you should be able to add your combo box tool to the ribbon:
<igr:XamWebRibbonTabItem>
<igr:XamWebRibbonGroup>
<cust:ComboBoxTool ItemsSource="{StaticResource inventory}">
</cust:ComboBoxTool>
</igr:XamWebRibbonGroup>
</igr:XamWebRibbonTabItem>
Now, a few things to keep in mind. First and most importantly, this will not work until after the first service release has gone out. This should be happening soon, but I just wanted to make sure that was clear. Also, this is just a very basic implementation, you'll probably want to create different visual states for the control depending on where it was being displayed in the ribbon (QuickAccessToolbar, ApplicationMenu, Submenu, etc).
Now, you might be thinking, "but what if I don't want to do all of that?"
Rest assured we will be adding additional tools to the ribbon over time, and one of the first ones we do will most likely be a combo box, so if you can hold out for a bit we'll have you covered soon. But if you absolutely need a combo box right now, this other option is available for you.
Let me know if you run into any issues with this, I'll be glad to help.
Looks like I was wrong about that, you can't create custom tools that can be added to the ribbon at this time. But after the service release you will be able to. I'll be back shortly with some sample code and an explanation of how this will work.
This should be doable, I'm going to try to put together a sample and get back to you on this.