This project is read-only.


Jul 15, 2011 at 3:54 PM

How do I add some RibbonGroupBox in a RibbonTabItem programmatically?

Jul 18, 2011 at 3:52 AM

Try adding the RibbonGroupBox in edit mode or wpf code then setting it to collapsed = true. Now programmatically uncollapse and re-collapse it when needed. This will make it appear where ever you have placed it on the bar.

Jul 18, 2011 at 5:41 AM

In fact, I am developing a modular system, and I plan has several modules to load. I wanted these modules generate buttons in the menu. Thanks for the reply

I know little about WPF, can someone show me a similar example? I saw something about DependencyProperty, but it still fails.

Jul 28, 2011 at 9:40 AM
Edited Jul 28, 2011 at 10:02 AM

First of all, DependencyProperty is something that is used with animation, styling, binding, and more. Not exactly what you're looking for at this moment...

Second of all, I have developed some code that should do what you need. There is one thing you must do first though:

In your window's xaml file, make sure the tab you want to add the control to has a name. For example, if you have a tab item and its code is

<Fluent:RibbonTabItem Header="Home">

then change it so it's like this:

<Fluent:RibbonTabItem Header="Home" Name="HomeTab">

This will allow you to directly access the tab from your code.

Next, this is a code sample I quickly made up. It's in Visual Basic, but can quickly be converted to C#. It will create a new group called "New Group" and create a new Button called "New Button" in it. 

    Private Sub AddItem()
        Dim group As New Fluent.RibbonGroupBox
        'The header property determines the words that appear on the group or button.
        group.Header = "New Group"
        group.Icon = Nothing
        Dim but As New Fluent.Button
        but.Header = "New Button"
        'The SizeDefiniton property determines the size of the button. Use Large, Middle, or Small.
        but.SizeDefinition = "Large"
        'The Icon and LargeIcon properties determine the images that appear on the button (or group).
        'Use something other than Nothing, for "Nothing" will result in no images.
        but.Icon = Nothing
        but.LargeIcon = Nothing
        'This adds a handler for the Click event. When the button is clicked, the method Button_Click is called.
        AddHandler but.Click, AddressOf Button_Click
    End Sub