Image folder for RibbonView buttons

4 posts, 1 answers
  1. Eugene Bykov
    Eugene Bykov avatar
    9 posts
    Member since:
    Sep 2009

    Posted 18 Jan 2013 Link to this post

    Hello,
    I'm starting a new project (tending to be a large one in future), and as well starting with xaml, prism and RadControls (that we, honestly, tried for WinForms several years ago). Now for WPF and SL.

    Currently the question arised regarding paths in Silverlight RibbonView demo for "Paint with MVVM".

    Tha MainViewModel.cs contains this code:
    private const string format = "/RibbonView;component/Images/RibbonView/{0}/{1}";
     
    private string GetPath(string fileName)
    {
        string icon = string.Format(format, GetTheme(), fileName);
     
        return icon;
    }
    which in demo SL application results in a certain directory within the demos. The name of that directory does not have the name (or name part) "components". I used Procmon to understand where an application tries to locate the images, and it looks to me that it at first searches the drive root, starting with the folder named "RibbonView;component" and then the project folder, again starting with this wierdly named subfolder.

    I understand that somehow this semicolon should split the whole path into several, but apparently it does not. I tried to prepare my solution without other code, mostly just by copying whole viewmodels from the demos. But somehow Procmon shows that in case of demos individual folder names are returned, but in my case this concatenated folder is searched for, and obviously not located. Didn't find anything important in Docs for string.Format(string, object, object) eather.

    So, what this semicolon means here, and what is a best solution to load images in SL application for a dynamic RibbonView?
    Thank you!

  2. Eugene Bykov
    Eugene Bykov avatar
    9 posts
    Member since:
    Sep 2009

    Posted 21 Jan 2013 Link to this post

    Seems, I am getting to understand this.
    Please correct me if I'm wrong, the name before the semicolon is assembly name, whatever is after - is the path.
    I don't yet understand the "component" part. Seems this is not the part of a path, but some keyword?
  3. DevCraft banner
  4. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 21 Jan 2013 Link to this post

    Hi Eugene,

    The syntax you're referring to is used to access assembly resource files. Basically, when you include an image as a resource of your project, you can use it in your UI by providing a relative or absolute path to its location. For example you can create an Image control and set its Source property to "Example.png". This syntax declares a relative path to the image control and will tell the application to start looking for the Example.png image under the physical location of the file where the Image control is defined.

    However, another approach in this case is to use a syntax where you define the assembly in which the image resource is added and then the path to that image starting from the root level in the assembly: "/assemblyShortName;component/resourceLocation". This syntax isn't referring to the physical location of the image on the disk, but rather to its location in an assembly and it can be used to load images from external (to your application) assemblies as well. Please take a look at this article describing how to use and access resource files in a Silverlight application as it can give you a better understanding of the resource files concept in Silverlight.

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Eugene Bykov
    Eugene Bykov avatar
    9 posts
    Member since:
    Sep 2009

    Posted 21 Jan 2013 Link to this post

    Thank you!
    Now everything looks clear.
    BTW, found another blog post earlier today, I'll leave a link here, might be useful.
    http://manaspatnaik.com/blog/index.php/technology/silverlight-4/resource-in-silverlight-a-brief-overview-part-1-resource-files/822
Back to Top