Private Sub addRibbonGroup()
If xamRibbon.Tabs.Count < 1 Then
Return
End If
Dim igTabItem As RibbonTabItem = xamRibbon.Tabs(0)
'Add RibbonGroup
Dim ribbonGroup As New RibbonGroup()
ribbonGroup.Caption = "RibbonGroup Members"
igTabItem.RibbonGroups.Add(ribbonGroup)
'Add ButtonTool
Dim btnToolRemoveFromQAT As ButtonTool = ButtonToolButtonToolButtonTool()
btnToolRemoveFromQAT.Caption = "RemoveFromQAT"
'Add ToolTip
getRibbonScreenTip(btnToolRemoveFromQAT)
End Sub
'Create RibbonScreenTip
Private Sub getRibbonScreenTip(ByVal tool As ButtonTool)
'Create XamRibbonScreenTip
Dim ribbonScreenTip As New XamRibbonScreenTip()
'XamRibbonScreenTip
ribbonScreenTip.Header = "RibbonGroup.DialogBoxLauncherTool"
ribbonScreenTip.Footer = "Press F1 for more help."
ribbonScreenTip.Content = "The RibbonGroup.DialogBoxLauncherTool property has been set to a ButtonTool. You can right click on this tool to add it to the QAT."
If ribbonScreenTip.HasContentImage = False Then
ribbonScreenTip.ContentImage = getImageSource("images/icons/Ribbon/xamRibbonDefaultApplicationIcon.png")
End If
ribbonScreenTip.FooterSeparatorVisibility = Visibility.Visible
ribbonScreenTip.HeaderSeparatorVisibility = Visibility.Collapsed
'Create FooterTemplate
Dim template As New DataTemplate(GetType(StackPanel))
'root element
Dim elStackPanel As New FrameworkElementFactory(GetType(StackPanel))
Dim mImageSource As ImageSource = getImageSource("images/icons/Ribbon/xamRibbonDefaultApplicationIcon.png")
Dim mImage As New Image()
mImage.Source = mImageSource
Dim bcGround As Brush = Brushes.Bisque
elStackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical)
elStackPanel.SetValue(StackPanel.BackgroundProperty, bcGround)
elStackPanel.SetValue(StackPanel.WidthProperty, System.Convert.ToDouble(200))
elStackPanel.SetValue(StackPanel.HeightProperty, System.Convert.ToDouble(200))
'create child elements
Dim elImage As New FrameworkElementFactory(GetType(Image))
elImage.SetValue(Image.SourceProperty, mImageSource)
elImage.SetValue(Image.WidthProperty, System.Convert.ToDouble(150))
elImage.SetValue(Image.HeightProperty, System.Convert.ToDouble(150))
elImage.SetBinding(Image.SourceProperty, New Binding("Source"))
Dim elTextBlock As New FrameworkElementFactory(GetType(TextBlock))
elTextBlock.SetValue(TextBlock.TextProperty, "Sample Text")
elTextBlock.SetValue(TextBlock.WidthProperty, System.Convert.ToDouble(150))
elTextBlock.SetValue(TextBlock.HeightProperty, System.Convert.ToDouble(150))
'add child elements
elStackPanel.AppendChild(elImage)
elStackPanel.AppendChild(elTextBlock)
template.VisualTree = elStackPanel
'Create HeaderTemplate
Dim template2 As New DataTemplate(GetType(TextBlock))
Dim elTextBlock2 As New FrameworkElementFactory(GetType(TextBlock))
elTextBlock2.SetValue(TextBlock.TextProperty, "Header Text")
elTextBlock2.SetValue(TextBlock.WidthProperty, System.Convert.ToDouble(150))
elTextBlock2.SetValue(TextBlock.HeightProperty, System.Convert.ToDouble(100))
template2.VisualTree = elTextBlock2
ribbonScreenTip.FooterTemplate = template
ribbonScreenTip.HeaderTemplate = template2
If TypeOf tool Is ButtonTool Then
Dim btn As ButtonTool = TryCast(tool, ButtonTool)
btn.ToolTip = ribbonScreenTip
End If
End Sub