views:

481

answers:

2

Hello,

Did anyone ever try to create a jQuery "LightBox"-Like "Popup" (WPF UserControl) for displaying Images? See this page for an example: http://www.huddletogether.com/projects/lightbox2/

Thanks!

+4  A: 

Hello Joseph,

Here is a site that appears to have done it, but it is only version 0.5 and might change dramatically before 1.0:
http://leandrovieira.com/projects/jquery/lightbox/#

This should be what you're looking for, and here is a sample of their code to implement:

$(function() {
    $('#gallery a').lightBox({fixedNavigation:true});
});

I hope this helps,

Thanks!


EDIT:

Sorry that I didn't fully understand what you ment in version one of your question. Here is an updated answer (with code / source) to your question.

First I created a control that will act as a modal dialog box that grays everything out in the background. Then I added the ability to put a picture in there, with added ability to have a comment with each picture. Here are images of the final product:

First Image Loaded: First Image Loaded

Second Image Fading In: Second Image Fading In

Second Image Loaded: Second Image Loaded

I also added animations to resize the images like the Lightbox project does. I added the ability to have a forward and back buttons, accelerator keys, forward and back arrow control, and escape to exit. I think I've captured what you're looking for in this control.

As usual, I've uploaded the full source code to Google Code for your download.

The direct link to the zip file is here:
http://stackoverflow-answers-by-scott.googlecode.com/files/1755872.zip

I hope this helps,

Thanks!

Scott
Thanks Scott for the answer, but what I'm looking for is a WPF UserControl do to the same :-) Btw, at following page is a pretty solid jQuery script: http://www.huddletogether.com/projects/lightbox2/#download
Joseph Melettukunnel
I gotcha, I am sorry that I mis-read. I will get you an example (source) on a control that can do this. :-) Give me a little bit and I'l update my answer.
Scott
Thanks mate, that'd be great! I finished the the lightbox UserControl with Ray Burns idea, but it'd love to know how you'd do it. Cheers
Joseph Melettukunnel
I got it done, too bad I didn't get it done before you accepted Ray's answer. :-( Maybe if it's a good enough answer you could switch it.. ;-)
Scott
Nice, works like a charm ;) Thanks Scott - hope this might help anyone else too.
Joseph Melettukunnel
Incredibly useful control, I borrowed it and rewrote it based off a ContentControl so I could stuff whatever I want inside the lightbox. Now I have a perfect way to handle views/controls that I want to be application modal.
vfilby
@vfilby - Thanks. If it is still similar code and you wanted to, I could make you a contributer to the Google code project and you could upload the patch. :) Thanks.
Scott
Ya @vfilby I'd like to see that too. @Scott. Good work, now I need to understand it.
nportelli
+2  A: 

Duplicating the functionality you linked to is absolutely trivial in WPF. Just:

  1. Create a UserControl with a single ItemList property of type IEnumerable<ImageSource>
  2. Add a Popup to the UserControl
  3. Add a Grid to the Popup that lays out the LightBox the way you want, including panels for the Image, TextBlock, and Button
  4. Add a StoryBoard that is triggered by the Loaded event that animates the changes.
  5. Use an EventTrigger to set the Popup's IsOpen property to false when the button is clicked
  6. Bind the Image.Source to {Binding ItemList/} to show the current item in the ItemList
  7. Add a Background="Transparent" rectangle to each side of the Grid that runs code-behind to change the current item in ItemList
  8. Optionally also repeat the BeginStoryboard when changing the current item
Ray Burns