Solved

WPF Border from Image

Posted on 2010-08-19
2
1,043 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now