?
Solved

WPF Border from Image

Posted on 2010-08-19
2
Medium Priority
?
1,058 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

770 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