What we have to do:
- make a class for photos
- make a template for the gallery
- make a listbox, which will represent gallery
- make a list of pictures (use some dummy data)
- join this list to our listbox
- make a detail of picture
- activate our gallery
Note: If you have not Silverlight 3 beta 1 installed, you could use Silverlight Toolkit as wall. You have just add libraries of SL Toolkit to your project before you start.
1. make a class for photos

For this example we could need just two attributes - name and source (in source you could use a string).

2. make a template for the gallery
We have to make two templates. First one for item and second one for whole gallery. And in this case we use new Silverlight 3 control WrapPanel as PanelTemplate.

3. make a listbox representing gallery
The important thing is to set ItemsPanel and ItemTemplate, which we made before.

4. make a list of pictures
I have already used paintings of my friend (which is not dummy, of course:).

5. join list of picures to our listbox

6. make a detail of picture

I have used some black rectangle with 80% opacity to hide gallery at background.

And now you have to paste this UserControl to our MainPage.xaml, becaouse you want to show preview above gallery. You will do that by this two lines of code in bottom of MainPage.xaml.

Remember, if you want to paste some UserControl to an other, you have to set a namespace of project to header.

7. activate our gallery
This is the most interesting part.
The event in ListBox which will handle with detail is SelectionChanged. We have just set the DataContext and set Visibility of our Detail to visible.

Now, we have to make any exit from detail. The easiest way to do that is use main grid event MouseLeftButtonDown to set visibility of Detail to Collapsed.

That's it. Now you can run your gallery :-)
Download - source code [16511585kB].
I hope you will enjoy it.




1 comments:
link your gallery is broken, can you provide a good one
Post a Comment