Adding combobox to Ribbon Control in XAML

Total Post:117

Points:821

WPF 
WPF
 2716  View(s)
Ratings:
Rate this:

I have a WPF Application with a Ribbon Control. I want to add a ComboBox, to show the logged in user next to the help button. But when I try to add the ComboBox, it is created as a Tab.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <Ribbon x:Name="RibbonWin" SelectedIndex="0" Margin="0,0,0,113">
        <Ribbon.HelpPaneContent>
            <RibbonButton SmallImageSource="Images\help.png"></RibbonButton>
        </Ribbon.HelpPaneContent>
        <RibbonComboBox>
            <ComboBoxItem Content="Test1"/>
        </RibbonComboBox>
        <RibbonTab Header="Home" KeyTip="H" Margin="0,0,0,-1" >
            <RibbonGroup x:Name="ClipboardGroup" Header="Clipboard">
                <RibbonMenuButton LargeImageSource="Images\paste.jpg"Label="Paste" KeyTip="V">
                    <RibbonMenuItem ImageSource="Images\paste.jpg"Header="Keep Text Only" KeyTip="T"/>
                    <RibbonMenuItem ImageSource="Images\paste.jpg"Header="Paste Special..." KeyTip="S"/>
                </RibbonMenuButton>
                <RibbonButton SmallImageSource="Images\cut.jpg"Label="Cut" KeyTip="X" />
                <RibbonButton SmallImageSource="Images\copy.jpg"Label="Copy" KeyTip="C" />
            </RibbonGroup>
            <RibbonGroup x:Name="Questions" Header="Questions And Answers">
                <RibbonMenuButton LargeImageSource="Images\Question.jpg"Label="Questions" KeyTip="V">
                    <RibbonMenuItem ImageSource="Images\paste.jpg" Header="Add Question" KeyTip="T"/>
                    <RibbonMenuItem ImageSource="Images\paste.jpg" Header="Paste Special..." KeyTip="S"/>
                </RibbonMenuButton>
                <RibbonButton SmallImageSource="Images\Save.jpg" Label="Save" KeyTip="X" />
                <RibbonButton SmallImageSource="Images\Add.jpg" Label="Add" KeyTip="C" />
            </RibbonGroup>
        </RibbonTab>
        <RibbonTab Header="Insert" KeyTip="I">
        </RibbonTab>
        <RibbonTab Header="PageLayout" KeyTip="L">
        </RibbonTab>
    </Ribbon>
</Grid>

Also is there a way to remove the the Application Menu ComboBox on the left that is created by default.

  1. Re: Adding combobox to Ribbon Control in XAML

    Hi Jay, 


    Put a RibbonApplicationMenu into the ApplicationMenu-property and set its Visibility to 'Collapsed'. This will not remove the application menu, but at least it is not longer visible. There is not other way to hide it.

    The ComboBox must be inserted into a RibbonTab, so a RibbonTab will be created implicitly if you do not specify anyone.

    The following example demonstrates how to hide the application menu and insert a combo box:

    <Ribbon>
        <Ribbon.ApplicationMenu>
            <RibbonApplicationMenu Visibility="Collapsed"></RibbonApplicationMenu>
        </Ribbon.ApplicationMenu> 
        <RibbonTab>
            <RibbonGroup>
                <RibbonComboBox></RibbonComboBox>
            </RibbonGroup>
        </RibbonTab>
    </Ribbon>

      Modified On Apr-04-2018 06:00:19 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.