Jul 28, 2011 at 8:40 AM
Edited Jul 28, 2011 at 9: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
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