Home > DeveloperSection > Forums > Adding combobox to Ribbon Control in XAML
jayprakash sharma
jayprakash sharma

Total Post:117

Points:821
Posted on    August-19-2014 3:14 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 1316  View(s)
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.



Pravesh Singh

Total Post:411

Points:2881
Posted on    August-19-2014 3:35 AM

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>


Don't want to miss updates? Please click the below button!

Follow MindStick