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:
I need to do this in code-behind though. This works for now:
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.
What happens if you use this for the URI:
where "Framework" is the assembly name.
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?
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.
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.