Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WPF VB.NET
Hi everyone
i have 3 BitmapImage in my resources like this :
<BitmapImage x:Key="ImageSource_1" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="E:\Original Compiler\VIS Management\VIS Management\VIS Management\Images\BrowsersIcons\1.jpg"/>
		<BitmapImage x:Key="ImageSource_2" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="E:\Original Compiler\VIS Management\VIS Management\VIS Management\Images\BrowsersIcons\2.jpg"/>
		<BitmapImage x:Key="ImageSource_E3" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="E:\Original Compiler\VIS Management\VIS Management\VIS Management\Images\BrowsersIcons\3.jpg"/>
 
I have a list and it has a field "Imagename" and it give to me a number from 1 to 3
Now i want get it number and convert it to my resources
but how can i do?
thank you
Posted 9-May-13 5:10am
Edited 9-May-13 5:12am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This might give you a starting point,
 
http://stackoverflow.com/questions/14259262/implementing-ivalueconverter-to-convert-string-to-image[^]
 
You will want to look at how to access resources within a resource dictionary through code as well because that will be how to retrieve the image.
  Permalink  
Comments
Sina asefi at 9-May-13 10:26am
   
First thank you for your response
it just explain about how can we convert a string address to image
but i get a number like 1 or 2 or 3 and i want return a staticresource by it
Pheonyx at 9-May-13 10:30am
   
In the value converter you create a switch statement for the object, if it is value 1, return the appropriate image, value 2, return appropriate image etc.
Sina asefi at 9-May-13 10:38am
   
I know i can use from this
Return New BitmapImage(New Uri("pack://application:,,,/Images/Icons/1.jpg"))
but i made 3 BitmapImage in my resourcedictionary and i want access to them Instead of direct access to files!
do you know how can i do that?
Pheonyx at 9-May-13 10:57am
   
Someone here appears to be doing something similar, they are accessing a template rather than an image but I believe the principle should be similar.
 
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/e2001a25-9ce2-4421-96b7-3dd42b601f1a/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 359
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100