'Declaration Public Property Image As ImageSource
public ImageSource Image {get; set;}
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; }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2