Solved

WPF Border from Image

Posted on 2010-08-19
2
1,053 Views
Last Modified: 2013-11-12
Hi to all,

I am starting a new project that will basically take an image and "frame" the image. We have a framing shop that wants a in store application to help users select the frame they need for their image. WPF seemed to be the best fit for this project.

How would I go about setting a border's "border" based from an image? I was thinking of placing an image inside a border to give the effect of a frame.

Any suggestions would be appreciated on this. If there are any samples that could help me I would appreciate that as well.

We will be using Visual Studio 2010 and .Net 4.0

Thanks
0
Comment
Question by:ALawrence007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
MikeToole earned 500 total points
ID: 33483578
There's no need for a border, just superimpose the picture on the frame, setting the margin of the picture image to the width of the frame's sides.

            <Grid>
                <Image Source="...TheFrame.jpg"/>
                <Image  Source="...ThePicture.jpg" Margin="40"/>
            </Grid>

You'd use data binding to set the source, probably setting the frame's source to the active item on a list box, which in turn would show the images of the frames to choose from.

There are tweaks for performance - the whole original image is loaded, then resized when you do it this way, the attached code from Microsoft documentation shows how to reduce the load.
<Image Width="200">
  <Image.Source>
    <!-- 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. -->
    <!-- Note: In order to preserve aspect ratio, only set either DecodePixelWidth
         or DecodePixelHeight but not both. -->
    <BitmapImage DecodePixelWidth="200"  
     UriSource="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg" />
  </Image.Source>
</Image>

Open in new window

0
 

Author Closing Comment

by:ALawrence007
ID: 33487050
Just what I was looking for!!! Thanks Mike!!
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question