Click here to Skip to main content
Rate this:
 
Please Sign up or sign in to vote.
See more: C# WPF
how to get the control inside image in wpf
Posted 10-Feb-13 1:14am
Edited 10-Feb-13 2:05am
Joezer BH38.4K
v2
Comments
   
What is that supposed to mean?
—SA

1 solution

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

Solution 1

The source of the image can be used like:
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:
// 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
  Permalink  
Comments
   
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
Edo Tzumer 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...]
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Web01 | 2.8.160204.4 | Advertise | Privacy
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service

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