Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 377171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:40:13+00:00 2026-05-12T14:40:13+00:00

I’m using the WPF Office Ribbon, and I have a content view that I

  • 0

I’m using the WPF Office Ribbon, and I have a content view that I would like to have add new items to the ribbon when that view becomes active. I have code that adds a new RibbonCommand as well as a new RibbonButton to the group I want, but nothing happens when I add it. However, if I add a new group with the button, it comes up fine and is bound correctly. Is there some method to get it to update that I’m missing? I’ve tried UpdateLayout() and it does not work either. I’d really like to try and avoid rebuilding all the groups everytime the view changes.

Works:

public void InjectItems(IView view)
{
var ribbonCommands = ProcessRibbonCommands(view.GetViewModel().Tasks, view.GetType());
var group = new RibbonGroup();
group.Command = new RibbonCommand() { LabelTitle = "Group Test" };            

foreach (RibbonCommand command in ribbonCommands)
{
    shell.MainRibbon.Resources.Add(command.Name, command);
    group.Controls.Add(new RibbonButton { Command = command });
}

shell.MainRibbon.SelectedTab.Groups.Add(group);
}

Doesn’t Work:

public void InjectItems(IView view)
{
var ribbonCommands = ProcessRibbonCommands(view.GetViewModel().Tasks, view.GetType());
var group = shell.MainRibbon.SelectedTab.Groups[0]; //I have a default group, will fix later

foreach (RibbonCommand command in ribbonCommands)
{
    shell.MainRibbon.Resources.Add(command.Name, command);
    group.Controls.Add(new RibbonButton { Command = command });
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:40:14+00:00Added an answer on May 12, 2026 at 2:40 pm

    I’m assuming you’re using the Microsoft Ribbon CTP from the OfficeUI site.

    As part of the licensing agreement there are a number of style guidelines that you are expected to follow. One of them is that you don’t add/remove contents of the Ribbon based on your current view.

    from the doc:

    Controls displayed in a group MUST NOT change as a result of selection. If a control is not active, the
    control MUST be grayed out, rather than removed from the group. This provides a more predictable
    experience and prevents the layout of controls on the Ribbon from changing and distracting users.

    that being said, it sounds like a Context tab is exactly what you’re looking for. These can be disabled and enabled but the actual contents of the tab don’t change.

    This is the code to create a context tab in XAML:

    <!--Context Groups-->
            <r:Ribbon.ContextualTabGroups>
                <!--Piece Contextual Group-->
                <r:RibbonContextualTabGroup x:Name="grpPieceContext" Label="Piece Tools">
                    <r:RibbonTab Label="Piece Information" Name="tabPieceContextInfo">
                        <r:RibbonGroup Name="grpPieceDetails" Command="{StaticResource PieceInformationGrpCommand}">
                            <r:RibbonLabel x:Name="lblPieceTag"/>
                            <r:RibbonTextBox Name="txtPieceDescription" Command="{StaticResource PieceNameTextboxCommand}" 
                                             TextChanged="txtPieceDescription_TextChanged" MaxLength="32"/>
                            <r:RibbonLabel x:Name="lblPieceLocation"/>
                        </r:RibbonGroup>
                    </r:RibbonTab>
                </r:RibbonContextualTabGroup>
            </r:Ribbon.ContextualTabGroups>
    

    you can then active and de-active the tab via this code:

            if (!this.grpPieceContext.IsActive)
            {
                this.grpPieceContext.IsActive = true;
                this.grpPieceContext.Color = Colors.Orange;
            }
    

    where orange is the color that sits in behind the context group.

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.