[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

WPF Border from Image

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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 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