This is a migrated thread and some comments may be shown as answers.

RadRibbonGroup.LargeImage

3 Answers 161 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
TRW
Top achievements
Rank 1
TRW asked on 19 Nov 2015, 10:32 PM

Hi!

I need use a different image from data base, i will asign the image(PNG) in order of an specific process.

The images recovered from data base are created in a temporal folder in order to use them in the dynamic process when i need chage the image.

At this moment the asignation of an image is ok but i can not see the image in the button:

RadRibbonButton objArea = new RadRibbonButton();
objArea.LargeImage = new BitmapImage(new Uri(auxPath + (string)dt.Rows[i].ItemArray[1], UriKind.Relative));
objArea.Size = Telerik.Windows.Controls.RibbonView.ButtonSize.Large;

If i use a RadRibbonButton created manually in xaml, i can change the image and the result is ok.

//control created in xaml
btnExample.LargeImage = new BitmapImage(new Uri(auxPath + (string)dt.Rows[i].ItemArray[1]));

If you help me i will be greateful.

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 24 Nov 2015, 05:21 PM
Hello,

I wasn't able to reproduce the described behavior. Can you please take a look at the attached project and let me know if I am missing something? Also, please make sure that the BitmapImage object gets a valid Uri that points to the specific image file.

Regards,
Dinko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
TRW
Top achievements
Rank 1
answered on 25 Nov 2015, 02:06 PM

Thanks Dinko!

I solved this item using a RadRibbonButton created manually with LargeImage alrady seted and copy some properties to the new dynamic buttons, that was the only way to add the image to the RadRibbonButton. I checked your example, i have a detail, I am using image from data base for that reason I don't have the images in the project.

This is the code I used to create the image:

01.private static BitmapImage GetImage(byte[] data, string imgName)
02.{
03.    MemoryStream ms = new MemoryStream(data);
04.    System.Drawing.Image img = System.Drawing.Image.FromStream(ms, true);
05.    ms.Close();
06. 
07.    string auxPath = AppDomain.CurrentDomain.BaseDirectory + @"\temp\";
08.    if (!System.IO.Directory.Exists(auxPath))
09.        System.IO.Directory.CreateDirectory(auxPath);
10. 
11.    img.Save(auxPath + imgName, ImageFormat.Png);
12. 
13.    return new BitmapImage(new Uri(auxPath + imgName));
14.}
 

And the code for assign to the new RadRibbonButton the image

01.objArea.LargeImage = btnExc.LargeImage;
02.NLI_DataObject objImg = NLI_ViewModel.GetData(objZone.IdImage);
03.objArea.LargeImage = objImg.NewImage;
04. 
05.public static NLI_DataObject GetData(int idImage)
06.{
07.    DataTable dt = SQLComm.App.FATT.NewLargeImage.GetImageFromDB(idImage);
08. 
09.    NLI_DataObject obj = new NLI_DataObject();
10.    obj.NewImage = GetImage((byte[])dt.Rows[0].ItemArray[0], (string)dt.Rows[0].ItemArray[1]);
11. 
12.    string[] extAux = dt.Rows[0].ItemArray[1].ToString().Split('.');
13.    obj.OnlyName = extAux[0];
14.    obj.OnlyExt = extAux[1];
15.    obj.ImageName = (string)dt.Rows[0].ItemArray[1];
16. 
17.    return obj;
18.}

 

 Regards,

JGC.

 

 

0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 27 Nov 2015, 04:23 PM
Hi JGC,

From your last reply, it's not clear that you solved the issue or you need further assistance. Can you confirm that you find a solution for your case?

We are looking forward to your reply.

Regards,
Dinko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
RibbonView and RibbonWindow
Asked by
TRW
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
TRW
Top achievements
Rank 1
Share this question
or