{Dev Tricks} » silverlight http://dev-tricks.net Blogging developper tips and tricks Sun, 30 Aug 2009 00:14:47 +0000 http://wordpress.org/?v=2.9.2 en hourly 1 Silverlight Tutorial – Flashlight Tutorial http://dev-tricks.net/silverlight-flashlight-tutorial http://dev-tricks.net/silverlight-flashlight-tutorial#comments Mon, 19 Jan 2009 20:48:13 +0000 Antoine Angot http://dev-tricks.net/?p=80 How to make a flashlight effect with silverlight ?
 
 

 
 

    What you need :
     

  • be familiar with Blend
  • be familiar with Visual Studio
  • half an hour
     
     
     

    Introduction

     
    Many years ago, a friend taught me how to make a flash light effect with flash.
    You probably saw it in many tutorials.
     
     

     
    Today, we will try to do better with silverlight :)

     
     
     

    The Blend Part

     

      Create a new project

     
    I’m doing it with Blend, but you can use Visual Studio if you want.

      I’m doing it with Blend, but you can use Visual Studio if you want.

     
     

      Add an image

     

      Add it to the project.

     
     

      Resize the image to give it the same size that the LayoutRoot

     
     

      Draw a rectangle

     
     

      select the tool

     
     

      You should get this.

     
     

      Gradient Brush and Radial Gradient

     
     

      Set up the rectangle background as a gradientbrush

     
     

      And click on the radial gradient option

     
     

      You rectangle should look like this.

     
     

      Transparency

     
     

      Set the first gradiant to black

     
     

      For the other one, same color but set transparenrcy to half

     
     

      We begin to see the final result
       
       

      Draw your Flashlight

     
     

      Play with gradiant and try to make something which looks like a light.

     
     

      Here is the artistical part :)

     
     

      Well, i think i’m fine.

     
     

      For me, it looks like this.

     
     

      Transform the Brush

     
     
    if you want to be able to move, you have to enlarge the brush.
     

      Select the “Brush Transform” tool.

     
     

      Resize the brush to about one and half.

     
     
     
     

    The Visual Studio part

     

     

    Ok this part is ridiculous you have to add a method in FlashLight.xaml.cs to register mouse move.
     

    Unable to get source code, check your URL given in [viewcode].

    Download this code: FlashLight.cs

     
     
     

    Conclusion

     
     
    Actually, i’m pretty sure that you can do the same with the last version of Flash but this tutorial is a good exercise to practice with Blend.
    Thanks for reading. You can download the source code here.
     
     

]]>
http://dev-tricks.net/silverlight-flashlight-tutorial/feed 0
Silverlight Custom Control – I http://dev-tricks.net/silverlight-custom-control-i http://dev-tricks.net/silverlight-custom-control-i#comments Wed, 14 Jan 2009 16:31:49 +0000 Julien Palard http://dev-tricks.net/?p=76 This article is my first about creating Custom Controls in Silverlight 2.
So let’s build a simple one :
You need :

  • A .cs file, named with your new Custom Control name
  • A directory named Themes
  • A generic.xaml file in it (just delete generic.xaml.cs if it was created)

Silverlight Custom Control Tree in Visual Studio

A basic custom control .cs file (the logic part):

Unable to get source code, check your URL given in [viewcode].

Download this code: EditableTextBlock.cs

A basic custom control generic.xaml file (the graphic part):

Unable to get source code, check your URL given in [viewcode].

Download this code: generic.xaml

Now, to test, you need to add the xmlns of your namespace, and add the usercontrol :

Unable to get source code, check your URL given in [viewcode].

Download this code: page.xaml

In the next article, we’ll see how to bind properties with TemplateBinding.
Don’t forgot to read the MSDN !

]]>
http://dev-tricks.net/silverlight-custom-control-i/feed 1
How to make a fake 3D Storyboard with Expression Blend http://dev-tricks.net/fake-3d-with-blend http://dev-tricks.net/fake-3d-with-blend#comments Sun, 24 Aug 2008 23:41:34 +0000 Antoine Angot http://dev-tricks.net/?p=29 In this “how to” i will show you how to make a StoryBoard like this:

This is not hard but you have to be famialiar with Blend.

download this video

]]>
http://dev-tricks.net/fake-3d-with-blend/feed 0
Silverlight – Password field no longer missing http://dev-tricks.net/silverlight-password-field-no-longer-missing http://dev-tricks.net/silverlight-password-field-no-longer-missing#comments Thu, 14 Aug 2008 16:52:38 +0000 Julien Palard http://dev-tricks.net/?p=8 EDIT : There’s now a real PasswordField, our tricks is no longer needed, just read :
http://silverlight.net/blogs/msnow/archive/2008/09/29/silverlight-tip-of-the-day-47-how-to-implement-a-password-box.aspx

Everybody developping in Silverlight knows that there’s no password textbox, and some of us rewrite a UserControl to replace it… yeark !!
There’s a so simple way to create a password textbox :
Use a TextBox and change the font with a home made font in which all characters are ‘*’ …
0 lines of code, do it in XAML

Unable to get source code, check your URL given in [viewcode].

Download this code: password.xml

FontFamily can download a file and pick a font from this file, the syntaxe is given “file.ttf#fontname” in my password.ttf the font name is “Password”, with the .ttf have to be in your ClientBin (relatives or absolute URI can be used with nothing, the root directory is checked, so put it in your ClientBin)
According to TimHeuer’s comment, after beta 2, embedding fonts will not work with this way, so watch his video Using custom fonts in silverlight to do it with the right way :)

Dont want to create a .ttf ? download mine. password.ttf

]]>
http://dev-tricks.net/silverlight-password-field-no-longer-missing/feed 13