RadRibbonGroup.LargeImage

4 posts, 1 answers
  1. TRW
    TRW avatar
    4 posts
    Member since:
    Dec 2011

    Posted 19 Nov 2015 Link to this post

    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.

  2. Dinko
    Admin
    Dinko avatar
    204 posts

    Posted 24 Nov 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. TRW
    TRW avatar
    4 posts
    Member since:
    Dec 2011

    Posted 25 Nov 2015 Link to this post

    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.

     

     

  5. Answer
    Dinko
    Admin
    Dinko avatar
    204 posts

    Posted 27 Nov 2015 Link to this post

    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
Back to Top