Design a Vista-like account display picture for Silverlight application

by Andrej Tozon 31. January 2009 17:52

If you like the way how Windows Vista shows your account picture on the Login screen, or how Windows Live Messenger’s display picture looks like on, you have probably already thought about putting something like it in your Silverlight application, either for a login screen or just to display a picture in a nice frame.

To take a short break from coding, I’m going to write about how to design a frame, similar to what the above examples use, and put it on a Silverlight page.

I’ll start by opening Expression Design.

Create a new document, then select a Rectangle tool and draw two squares on the canvas. Their size should be set to 110x110 and 97x97. Make sure the stroke of both is set to 1 px width, black.

Set the smaller square’s Corner Radius to 2 px, and the bigger one should be set to 4px.

With the bigger square selected, select Object | Envelope Distort | Make Warp Group then decrease group’s resolution by selecting Object | Envelope Distort | Decrease Resolution.

Squares

With the Direct Selection tool selected, select each of the four handles on the sides (not corners) and move them away from the center by approx. 4 px.

Rectagle

With the square still selected, select Object | Envelope Distort | Edit Warp Group.

In the Properties window, under Appearance, select Fill Gradient Color tool. Choose your base color (I’ve chosen one from the default set) and build a custom gradient on it. Setting it up like this:

Gradient

got me this:

Gradient

Return to the main panel. If the square isn’t updated with the gradient, do something to it to get it refresh itself.

Now, select both rectangles and align them vertically and horizontally (Arrange | Align | Vertical Centers, Arrange | Align | Horizontal Centers). If the smaller square disappears (falls behind the bigger one), send the big one to back (Arrange | Order | Send to Back).

Select the smaller square and set its fill color to White and allow some transparency (80% Opacity in this case).

Voila:

Picture frame

If that's not enough, you can experiment by setting the outer square’s stroke color to a lighter black/grey, add a drop shadow, etc. Expression Design allows great effects to be applied to your objects, would be a waste not to use them :)

Now, for the Silverlight part…

Select Edit | Options | Clipboard (XAML)… Set Clipboard format to XAML Silverlight Canvas. You can uncheck the Place grouped objects in a XAML layout container option.

Group all objects (Arrange | Group) into one group and move the whole thing into left top corner. Edit | Copy XAML (Ctrl+Shift+C) and paste into your Silverlight page (Xaml view).

Note: all of the above applies if you’re building a display picture for your WPF application too. Just select the proper Clipboard/XAML settings in Expression Designer and you’re ready to go.

Now, replace the Canvas declaration with a Grid and remove all Canvas-related attributes from its child elements.

Now you can fill the empty content with a picture of your choice.

Display picture

In one of the forthcoming posts I’ll make this a custom control and most likely build a multiple user login screen, but in a rather unusual way ;)

Tags:

Development | MVVM | Silverlight | WPF | Design

Comments

1/31/2009 9:28:03 PM #

trackback

Trackback from Community Blogs

Silverlight Cream for January 31, 2009 -- #503

Community Blogs | Reply

1/31/2009 10:59:33 PM #

Ramprasad

Hi Andrej,

Thanks for this blogpost. After the design my XAML looks like this..

<Path Width="126.462" Height="122.761" Canvas.Left="309.476" Canvas.Top="188.129" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FF9CDDF3" Data="F1 M 316.241,192.877C 331.458,191.236 346.68,189.348 361.975,188.782C 373.147,188.369 384.359,188.825 395.499,189.763C 403.693,190.453 411.866,191.368 420.037,192.295C 422.314,192.554 424.591,192.813 426.868,193.069C 428.336,193.234 429.914,193.195 431.223,193.878C 432.665,194.631 433.678,196.344 433.906,197.954C 434.929,221.947 435.904,245.983 435.196,269.987C 434.972,277.589 434.651,285.187 434.318,292.785C 434.22,295.017 434.121,297.249 434.023,299.482C 433.96,300.918 434.109,302.455 433.514,303.764C 432.847,305.23 431.181,306.29 429.6,306.598C 403.215,309.149 376.557,311.714 350.132,309.618C 341.855,308.962 333.6,308.048 325.349,307.12C 323.181,306.875 321.013,306.63 318.844,306.388C 317.443,306.232 315.926,306.276 314.69,305.598C 313.252,304.81 312.306,303.06 312.064,301.438C 310.696,277.192 309.323,252.869 310.312,228.604C 310.615,221.182 311.051,213.766 311.505,206.352C 311.638,204.18 311.772,202.009 311.905,199.838C 311.991,198.439 311.878,196.942 312.467,195.669C 313.125,194.249 314.709,193.195 316.241,192.877 Z "/>
        <Path Width="98.0005" Height="105.462" Canvas.Left="323.5" Canvas.Top="196.769" Stretch="Fill" StrokeLineJoin="Round" Stroke="#CD000000" Fill="#CDFFFFFF" Data="F1 M 326,197.269L 419,197.269C 420.105,197.269 421,198.164 421,199.269L 421,299.731C 421,300.836 420.105,301.731 419,301.731L 326,301.731C 324.895,301.731 324,300.836 324,299.731L 324,199.269C 324,198.164 324.895,197.269 326,197.269 Z " />


But how to add a picture into the inner rectangle. You missed out that step in your blogpost

Ramprasad India | Reply

2/1/2009 6:32:17 AM #

andrej

Ramprasad,
thank you for your comment. Once you put your Paths inside a grid, you can easily add a picture to the mix:
<Grid>
    <Path Width="117" Height="117" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF9C9C9C" Data="...">
        <Path.Fill>
            ...
        </Path.Fill>
    </Path>
    <Path Width="98" Height="98" Stretch="Fill" StrokeLineJoin="Round" Stroke="#CD000000" Fill="#CDFFFFFF" Data="..."/>
    <Image Source="[yourImageUrl]"  Width="96" Height="96" />
</Grid>

[Path data trimmed for simplicity]

I'll make an user control out of it in one of the future posts.

andrej | Reply

2/2/2009 5:56:02 AM #

trackback

Trackback from DotNetShoutout

Andrej Tozon's blog | Design a Vista-like account display picture for Silverlight application

DotNetShoutout | Reply

2/20/2009 6:00:59 PM #

pingback

Pingback from designerwpf.com

Designer WPF  » Blog Archive   » Bookmarks for February 20th

designerwpf.com | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading





Andrej Tozon

MVP - Client Application Developer

Microsoft Certified Solution Developer

MSN Alerts

View Andrej Tozon's profile on LinkedIn

Subscribe to me on FriendFeed

Andrej Tozon's Facebook profile

Get help from Andrej Tozon!

RecentComments

Comment RSS