none
image path WPF

    Question

  • Ok so I'm using an Infragistics OutlookBar and trying to set the icon to an image.  In XAML, no prob, I just do this for the LargeImage prop:

    <

     

    igOB:OutlookBarGroup x:Name="Tab1"

     

    Header="Tab One"

     

    LargeImage="Images\addbk_24x24.png">

     

     

    </igOB:OutlookBarGroup>

    I need to do this in code-behind though.  This works for now:

    TabGroup.LargeImage =

    new BitmapImage(new Uri(@"C:\Projects\CMDL NET\CMDL.MissionLoaderTool.Framework\Images\prefs_16x16.png", UriKind.RelativeOrAbsolute));

     

    ...But how can i do it without that whole path (C:\...)?  The image is in a folder called Images in project "Framework" with a bunch of other images that are being used through the XAML, so I can't move it or aynthing.

    Monday, May 03, 2010 12:31 PM

Answers

  • What happens if you use this for the URI:

     

    @"pack://application:,,,/Framework;component/Images/prefs_16x16.png"

    where "Framework" is the assembly name.

     

    M

    Monday, May 03, 2010 12:37 PM

All replies

  • What happens if you use this for the URI:

     

    @"pack://application:,,,/Framework;component/Images/prefs_16x16.png"

    where "Framework" is the assembly name.

     

    M

    Monday, May 03, 2010 12:37 PM
  • Mike-

    TabGroup.LargeImage =

    new BitmapImage(new Uri("pack://application:,,,/CMDL.MissionLoaderTool.Framework;Component/Images/prefs_16x16.png"));

    works.  But is this a relative path or not?  just trying to make sure when someone else builds and uses this one a different machine it'll work for them too.  I also didn't put the @ in there, do i need to for something?

    Monday, May 03, 2010 3:23 PM
  • That's an absolute path. The '@' symbol was included because I did a copy and paste from your post. The '@' symbol is not a requirement, just a preference on how you want to performing string escaping (i.e. "C:\\Folder\\Sub Folder" vs @"C:\Folder\Sub Folder"), among other things.

     

    Mike

    Monday, May 03, 2010 3:36 PM
  • ok thanks!  forgive me, but how would i make this a relative path (and should i even need to anyway?) ?
    Monday, May 03, 2010 3:55 PM
  • You could also use "Framework;component/Images/prefs_16x16.png", which would be relative. I don't believe there's an advantage of one format over the other.

     

    M

    Monday, May 03, 2010 6:04 PM