Private xamApplicationMenu As ApplicationMenu Private xamRibbon As XamRibbon Private Sub initRibbonItems() 'Create RibbonWindowContentHost Dim xamContentHost As New RibbonWindowContentHost() Me.Content = xamContentHost 'Create XamRibbon object xamRibbon = New XamRibbon() xamContentHost.Ribbon = xamRibbon DockPanel.SetDock(xamRibbon, Dock.Top) 'Create Application Menu xamApplicationMenu = New ApplicationMenu() xamRibbon.ApplicationMenu = xamApplicationMenu 'Create Image for Application Menu Dim bmpImage As New BitmapImage() bmpImage.BeginInit() bmpImage.UriSource = New Uri("/images/icons/Ribbon/xamRibbonDefaultApplicationIcon.png", UriKind.RelativeOrAbsolute) bmpImage.EndInit() xamApplicationMenu.Image = bmpImage End Sub 'Get Image Source Private Function getImageSource(ByVal uriString As String) As BitmapImage Dim bmpImage As New BitmapImage() bmpImage.BeginInit() bmpImage.UriSource = New Uri(uriString, UriKind.RelativeOrAbsolute) bmpImage.EndInit() Return bmpImage End Function
private ApplicationMenu xamApplicationMenu; private XamRibbon xamRibbon; private void initRibbonItems() { //Create RibbonWindowContentHost RibbonWindowContentHost xamContentHost = new RibbonWindowContentHost(); this.Content = xamContentHost; //Create XamRibbon object xamRibbon = new XamRibbon(); xamContentHost.Ribbon = xamRibbon; DockPanel.SetDock(xamRibbon, Dock.Top); //Create Application Menu xamApplicationMenu = new ApplicationMenu(); xamRibbon.ApplicationMenu = xamApplicationMenu; //Create Image for Application Menu BitmapImage bmpImage = new BitmapImage(); bmpImage.BeginInit(); bmpImage.UriSource = new Uri("/images/icons/Ribbon/xamRibbonDefaultApplicationIcon.png", UriKind.RelativeOrAbsolute); bmpImage.EndInit(); xamApplicationMenu.Image = bmpImage; } //Get Image Source private BitmapImage getImageSource(string uriString) { BitmapImage bmpImage = new BitmapImage(); bmpImage.BeginInit(); bmpImage.UriSource = new Uri(uriString, UriKind.RelativeOrAbsolute); bmpImage.EndInit(); return bmpImage; }