views:

46

answers:

2

Hi All

I've only just started using WPF. (I'm a WinForms guy), and from what I can see, trying to simply drag an image onto the Window is a huge PAIN. There seems to be no way where you can just select an option to tell it what picture to put indide the image control. I've seen so many sites within the last 10 minutes with atleast 10lines of code just to insert animage into a window. Is there an easier way?

+1  A: 

Odd problem, the "Source" property of the Image control is the default one in the Property grid. Click the "..." button, click Add to navigate to the image file.

If you are using VS2008, you'll need to add the resource yourself. Right-click the project in Solution Explorer, Add + Existing Item, select "Image Files" and navigate to your image file. Compile. The resource will now be available in the combo box to select.

Hans Passant
Yeah, that's what I thought! But there's no "..." button showing up! Aahhhh! I'm scared :(
lucifer
It's just an empty combo box
lucifer
You must be using VS2008. Answer updated.
Hans Passant
+1  A: 

First, I recommend you download an evaluation copy of Expression Blend instead of trying to do your development in Visual Studio. Blend is a far, far better tool for creating WPF UIs and it integrates beautifully with Visual Studio.

For example, in Blend, it is as simple as dragging an image onto the window. When you do so, Blend creates this XAML:

<Image Source="Photos/WashingtonMonument.jpg" />

That said, I have no idea why you're seeing examples that require 10 lines of code to do this! It seems ridiculous to me when one line of very simple XAML will suffice.

Ray Burns