Jump to content

WPF?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Peacemaker

Peacemaker

    Newbie

  • Members
  • PipPip
  • 11 posts
My problem is:
In C#:
//load image from url
pictureBox1.ImageLocation = "url";
In WPF:
????????
In C#:
//Unload image
pictureBox1.image == null;
In WPF:
????????

How can i do this in WPF?:confused:

#2
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
Well, you have the image control in a tag, since it's XAML:
[COLOR=Green]<!-- Simple image rendering. However, rendering an image this way may not
     result in the best use of application memory. See markup below which
     creates the same end result but using less memory. -->[/COLOR]
[COLOR=Blue]<[/COLOR][COLOR=#A31515]Image[/COLOR] [COLOR=Red]Width[/COLOR][COLOR=Blue]=[/COLOR][COLOR=Black]"[/COLOR][COLOR=Blue]200[/COLOR][COLOR=Black]"[/COLOR] 
[COLOR=Red]Source[/COLOR][COLOR=Blue]=[/COLOR][COLOR=Black]"[/COLOR][COLOR=Blue]C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg[/COLOR][COLOR=Black]"[/COLOR][COLOR=Blue]/>[/COLOR]

[COLOR=Blue]<[/COLOR][COLOR=#A31515]Image[/COLOR] [COLOR=Red]Width[/COLOR][COLOR=Blue]=[/COLOR][COLOR=Black]"[/COLOR][COLOR=Blue]200[/COLOR][COLOR=Black]"[/COLOR][COLOR=Blue]>[/COLOR]
  [COLOR=Blue]<[/COLOR][COLOR=#A31515]Image.Source[/COLOR][COLOR=Blue]>[/COLOR]
    [COLOR=Green]<!-- To save significant application memory, set the DecodePixelWidth or  
     DecodePixelHeight of the BitmapImage value of the image source to the desired 
     height and 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. -->[/COLOR]
    [COLOR=Green]<!-- Note: In order to preserve aspect ratio, only set either DecodePixelWidth
         or DecodePixelHeight but not both. -->[/COLOR]
    [COLOR=Blue]<[/COLOR][COLOR=#A31515]BitmapImage[/COLOR] [COLOR=Red]DecodePixelWidth[/COLOR][COLOR=Blue]=[/COLOR][COLOR=Black]"[/COLOR][COLOR=Blue]200[/COLOR][COLOR=Black]"[/COLOR]  
     [COLOR=Red]UriSource[/COLOR][COLOR=Blue]=[/COLOR][COLOR=Black]"[/COLOR][COLOR=Blue]C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg[/COLOR][COLOR=Black]"[/COLOR] [COLOR=Blue]/>[/COLOR]
  [COLOR=Blue]</[/COLOR][COLOR=#A31515]Image.Source[/COLOR][COLOR=Blue]>[/COLOR]
[COLOR=Blue]</[/COLOR][COLOR=#A31515]Image[/COLOR][COLOR=Blue]>[/COLOR]
You can find more on this page that I have found using some website called Google: Image Class (System.Windows.Controls)
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics