Issue with image/icon on a button

Oct 3, 2011 at 4:25 PM

Hi All,

For some reason, I couldn't show an image/icon on a button that's in the main ribbon... Strangely the image or icon shows up in the toolbar for the same button.

        Dim ribbon As New Fluent.Ribbon
        ribbon.Name = "Ribbon"

        Dim tab As New RibbonTabItem
        tab.Header = "aTab"
        ribbon.Tabs.Add(tab)

        Dim group As New RibbonGroupBox
        group.Header = "aGroup"
        tab.Groups.Add(group)

        Dim button1 As New Button
        button1.Header = "Button1"
        button1.Icon = GetImageSource("/Images/test.png")  'No image in ribbon, toolbar shows image on button
        'button1.Icon = GetBitmapFrame("/Images/test.png")  'No image in ribbon, toolbar shows image on button
        'button1.Icon = "/Images/myImage.png"    'No Image on ribbon, no image on toolbar
        group.Items.Add(button1)

        Dim qami As New QuickAccessMenuItem
        qami.Header = "QAMI"
        qami.IsChecked = True
        qami.Target = button1
        ribbon.QuickAccessItems.Add(qami)

        Me.Grid1.Children.Add(ribbon)



    Private Function GetImageSource(ByVal imageName As String) As ImageSource
        Return New BitmapImage(New Uri(imageName, UriKind.Relative))
    End Function
    Private Function GetBitmapFrame(ByVal imageName As String) As BitmapFrame
        Dim streamResourceInfo As StreamResourceInfo = Application.GetResourceStream(New Uri(imageName, UriKind.Relative))
        Return BitmapFrame.Create(streamResourceInfo.Stream)
    End Function
I will appreciate if anyone could shed some light on this or help me out... Many thanks..

Nov 15, 2011 at 10:23 AM

Hi,

I remembered having the same problem: Images must be 96dpi. 

Hope it fixes things