We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Set a Icon to a GroupBarItem via C#

Hello,

I try to setup the Icoon of a groupbariten via C# but I am not succedding. The same icon is working in XAML however not in C#.

C# is not working:
GroupBarItem taskBarItem=new GroupBarItem();
BitmapImage image = new BitmapImage();
            
image.BeginInit();
image.UriSource = new Uri("/Icons/offers.png");
image.EndInit();

taskBarItem.HeaderImageSource = image;
taskBar.Items.Add(taskBarItem);

XAML is working:
            <syncfusion:GroupBarItem HeaderText="Test" Name="test"
                    ShowInGroupBar="True" HeaderImageSource="/Icons/offers.png" >
            </syncfusion:GroupBarItem>

1 Reply

SM Sugapriya Mariappan Syncfusion Team October 24, 2016 05:49 AM UTC

Hi Christian,

Thank you for contacting Syncfusin Support.

We have prepared a sample based on the code example which you have provided. In this sample,you need to define the path of the format to display the icon.

Please download the sample from the below link

Sample: https://www.syncfusion.com/downloads/support/forum/127033/ze/GroupBarItemIconWPFSample1692118573.zip 

Also check the code snippet and screenshot from the below

Code Snippet:


GroupBarItem taskBarItem = new GroupBarItem() { HeaderText = "Test" };
BitmapImage image = new BitmapImage();

image.BeginInit();
image.UriSource = new Uri("/Icons/offers.png", UriKind.Relative);
image.EndInit();

taskBarItem.HeaderImageSource = image;
taskBar.Items.Add(taskBarItem);


Screenshot:




Could you please check the above solution and let us know if it is helpful?

Regards,
M.Sugapriya

 


Loader.
Live Chat Icon For mobile
Up arrow icon