Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to get the control inside image in wpf
Posted
Updated 10-Feb-13 1:05am
v2
Comments
Sergey Alexandrovich Kryukov 10-Feb-13 8:52am    
What is that supposed to mean?
—SA

1 solution

The source of the image can be used like:
C#
ImageSource imageSource = new BitmapImage(new Uri("C:\\FileName.gif"));
image1.Source = imageSource;


The following example shows how to render an image 200 pixels wide using code:
C#
// Create Image Element
Image myImage = new Image();
myImage.Width = 200;

// Create source
BitmapImage myBitmapImage = new BitmapImage();

// BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg");

// To save significant application memory, set the DecodePixelWidth or  
// DecodePixelHeight of the BitmapImage value of the image source to the desired 
// height or width of the rendered image. If you don't do this, the application will 
// cache the image as though it were rendered as its normal size rather then just 
// the size that is displayed.
// Note: In order to preserve aspect ratio, set DecodePixelWidth
// or DecodePixelHeight but not both.
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
//set image source
myImage.Source = myBitmapImage;


Cheers,
Edo
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Feb-13 8:54am    
I'm afraid this is not an answer, and I don't think this question needs answer as it sounds like a gibberish to me; what is "control inside image"?!
(I did not vote this time.)
—SA
Joezer BH 10-Feb-13 9:37am    
Well, you're right of course.
The guy definitely has SOMETHING in mind.
Either you ditch him by saying that this kind of "question" is unaccepted, or try to help him out with expressing what he wants\needs\misses etc
I guess you are more of an A type than a B.
[perhaps everyone is a B type until they realize its impossible to solve the world's undefined problems...]
Sergey Alexandrovich Kryukov 10-Feb-13 9:44am    
I'm none of the types you described...
But without "expressing" the answer can only confuse.
—SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900