Développement web indépendant à Montpellier

Publié le lundi 13 avril 2009 13:59:01

Microsoft Silverlight : premiers pas

Il m'a fallu tout d'abord récupérer la suite en évaluation si vous ne la possédez pas déjà, elle est fournie gratuitement par Microsoft® pour une durée raisonnable, et sans restriction, ce qui est appréciable. Vous devez donc d'abord télécharger Microsoft® Expression® Studio 2 sur site de Microsoft, et disposer de Visual Studio 2008 SP1, et de son plugin Silverlight, pour commencer à développer.

Si vous ne disposez d'aucun de ces outils, les versions d'évaluation que nous avons utilisés sont disponibles à ces adresses :

Un fois tout ceci téléchargé et installé, nous pouvons commencer à travailler sur Silverlight, le but de cet article est de faire un .

Création du premier projet Silverlight

Un fois tout installé, nous créons notre premier projet Silverlight dans Visual Studio. J'ai eu une petite appréhension au début en voyant l'import de DLL (librairies externes), mais le tutoriel de Microsoft essaie de nous rassurer en précisant qu'il est possible d'héberger ses applications Silverlight sous Linux...

Le "hello world" de Microsoft Silverlight avec Visual Studio

Nous avons suivi le tutoriel de Microsoft : Silverlight Tutorial Part 1: Creating "Hello World" with Silverlight 2 and VS 2008 [en].

Ce hello world consiste à créer un bouton avec l'intitulé "Clic moi !" puis de changer son intitulé une fois cliqué.

Pour ceux qui ont déjà réalisé des projets en C# (CSharp) et ASP.net, cela semble être la même logique : avec pour chaque fichier XAML (eXtensible Application Markup Language - prononcez Zamel), le code behind associé. Les fichiers XAML sont des fichiers qui représentent l'interface utilisateur, et également les objets .NET qui composeront l'application Silverlight. Voici par défaut le fichier Page.xaml :

<UserControl x:Class="SilverlightApplication1.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">

    </Grid>
</UserControl>

Le fichier Page.xaml est le fichier de base (ce que index.html serait au web). Lorsque l'on compile le projet, on obtient un fichier .XAP (prononcez "zap"), la compression ZIP est utilisée pour minimiser le temps de téléchargement du client.

Le code behind

Le code behind est dans le fichier Page.xaml.cs, c'est ce code qui va controler l'application, voici le code crée par défaut par Visual Studio :

namespace SilverlightApplication
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }
    }
}


Création du bouton Silverlight

Nous allons créer le bouton directement dans Visual Studio : ajoutez à l'intérieur de la balise Grid le code suivant :

<Button x:Name="monBouton" Width="100" Height="40" Content="Clic moi !"  />

C'est très proche d'ASP.net au niveau du nomage. Nous allons maintenant attacher l'événement, ajoutez l'attibut Click à cette balise et l'auto-complétion proposera un nom de méthode automatiquement, nous obtiendrons ceci :

<Button x:Name="monBouton" Width="100" Height="40" Content="Clic moi !" Click="monBouton_Click" />

Création de l'événement

L'ajout de l'attribut Click à la balise Button aura contribué à créer la méthode monBouton_Click du coté du code Behind Page.xaml.cs, nous ajoutons le changement d'intitulé dans le corps de la méthode :

private void monBouton_Click(object sender, RoutedEventArgs e)
{
    this.monBouton.Content = "Merci pour le clic";
}

Voilà pour le premier pas, vous pouvez maintenant compiler l'application pour obtenir le résultat.

Intégration de l'animation Silverlight (.xap) dans la page

On l'intègre de la même manière qu'un objet multimédia Flash ou JavaFx : voir la première partie de l'article sur l'intégration des animations flash sans swfobject.

<object data="data:application/x-silverlight," type="application/x-silverlight-2" width="150" height="60">
    <param name="source" value="SilverlightApplication2.xap"/>
    <param name="background" value="white" />
    <param name="minRuntimeVersion" value="2.0.31005.0" />
    <param name="autoUpgrade" value="true" />
   <!--début alternative-->
    <a href="http://go.microsoft.com/fwlink/?LinkID=124807">
        <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Téléchargez Microsoft Silverlight" style="border-style: none"/>
    </a>
    <!--fin alternative-->
</object>

Notez la présence de la version minimum du runtime à avoir pour afficher l'animation (minRuntimeVersion), et le autoUpgrade, on se demande comment Microsoft va déployer Silverlight sur les postes clients, mais espérons que le déploiement se fasse sans douleur, et que les applications resteront compatible.

Le choix du lecteur Flash minimum à la compilation d'un projet et la prise en compte des versions antérieures sont des atouts indiscutables de Adobe® : chose qui n'est pas présente à ce chez Silverlight lorsqu'lon compile (peut-être ne l'ai-je pas noté).

Téléchargement

Vous pouvez télécharger le projet tel que nous l'avons réalisé :

Ce fichier contient :

  • l'intégralité du projet Silverlight (le .sln, le .csjproj)
  • les sources C#,
  • les sources XAML,
  • les fichiers compilés (.xap).

Conclusion :

Silverlight offre quelques aspects positifs :

  • le développement en C#, qui est un langage facile d'accès et dont la plupart des développeurs ont l'habitude (Java-like),
  • sa ressemblance de logique avec ASP.net en fait un atout pour les développeurs qui sont plus orienté applicatif,

Je suis plutôt enthousiaste à l'idée d'aller plus loin dans la découverte de Silverlight, à mon avis, l'un des facteurs clés du succès de la plate-forme sera sa capacité à plaire aux graphistes (Microsoft Expression) : on ne fera que très peu de sans ces derniers...

Il est un peu trop tôt pour faire un benchmark (comparaison) des technologies (Flash, JavaFX, Silverlight), Ce qu'on peut dire pour le moment :

  • Peu de déploiement (moins de 25% des internautes équipés selon Riastats [en])
  • une communauté assez faible.

Gageons que Microsoft® saura déployer son plugin, grâce à son produit phare Microsoft® Windows, et que la communauté se construira autour de la technologie Silverlight. Il est sans doute encore un peu tôt pour imaginer mettre en production des site internet avec objets Silverlight, mais c'est imminent.

Notez cet article !

  • Actuellement 0 sur 5 étoiles
  • 1
  • 2
  • 3
  • 4
  • 5

Note : 0/5 (0 notes attribuées)

Merci d'avoir participé !

Vous avez déjà noté cette page, vous ne pouvez la noter qu'une fois !

Votre note a été changée, merci de votre participation !

Bonne résolution ! j'arrête d'alourdir mes pages avec des boutons de partage, mais vous pouvez continuer de partager :-)

Commentaires

  1. Students who are in USA can now get a good quality essay help paper from MyAssignmenthelp.com. It is guaranteed to customers that the papers that they give meet the high university standards.

  2. mcafee ac... | how to activate mcafee antivirus |

    mcafee.com/activate have the complete set of features which can protect your digital online life of the computing devices, and it not only help you to protect it but also it can maintain the stability of your computer, increase the speed with inbuilt PC Optimisation tool.

  3. This is really a great stuff for sharing. Keep it up. Thanks for sharing.

  4. Really i appreciate the effort you made to share the knowledge. 

  5. microsoft... | microsoft-support/outlook-support |

    We provide Outlook customer service phone number or on Chat ,Outlook tech support phone number for recover outlook password recovery and other issues.

  6. Support For Adobe at Contactassistance.com is an online technical support company. We provide trustworthy tech support and services for the third party products.

  7. Looking for Aol Support? Call now on toll free number to get instant 24/7 email support AOL, AOL Mail Technical Support, Click here for more information.

  8. office.com/setup Online Help – Step by Step guide for office Setup, Download & complete installation online. We are providing independent support service if in case you face problem to activate or Setup office product.

  9. Enter Key for Office.com/setup, after purchasing Office from visit office.com/setup, sign in to your www.office.com/setup account then enter product key for Office Setup.

  10. norton.com/setup Online Help – Step by Step guide for Norton Setup, Download & complete installation online. We are providing independent support service if in case you face problem to activate or Setup Norton product.

  11. mcafee.com/activate have the complete set of features which can protect your digital online life the computing devices, and it not only help you to protect it but also it can maintain the stability of your computer, increase the speed with inbuilt PC Optimisation tool.
    http://...-activate/

  12. The blog is a spotlight for individuals, A blog that is so pure, lucky to read it.

  13. <a href="... | Term paper writing service |

    Are you need term paper help at this time, contact with MyAssignemnthelp.com, they offer term paper writing service online for 100+ subjects.
    https:/...paper.html

  14. df@gmail.com | college essay preparation service |

    Looks like the essayist has put a considerable measure of diligent work into this.

  15. cafee.com/activate have the complete set features which can protect your digital online and offline life of the computing devices, and it not only help you to protect it but also it can maintain the stability of your computer, increase the speed with inbuilt PC Optimisation tool.
    http://...e.services

    mcafee.com/activate have the complete set of features which can protect your digital online life of the computing devices, and it not only help you to protect it but also it can maintain the stability of your computer, increase the speed with inbuilt PC Optimisation tool.
    http://...ctivate.uk

    mcafee.com/activate have the complete set of features which can protect your digital online life of the computing devices, and it not only help you to protect it but also it can maintain the stability of your computer, increase the speed with inbuilt PC Optimisation tool.
    http://...tivate.xyz

    Roku.com/link provides the simplest way to stream entertainment to your TV. On your terms. Visit roku.com/link for Roku code linking to your Account.
    http://...comlink.co


    mcafee.com/activate have the complete set of features that protect your digital online and offline life of the computing devices, and it not only help you to protect it but also it can maintain the stability of your computer, increase the speed with inbuilt PC Optimisation tool.
    http://...ctivate.co

  16. Thanks a lot for the post. It has helped me get some nice ideas. I hope I will see some really good result soon.

  17. Dissertat... | Dissertation For Marketing |

    Well thanks for posting such an outstanding idea. I like this blog & I like the topic and thinking of making it right.

  18. Dave | Write My Paper for Me |

    Are you searching for online paper editors, and typing “looking for online experts to write my paper for me in USA.
    https:/...or-me.html

  19. online co... | online cost accounting help |

    Such a nice post, keep providing good resources.

  20. sf@gmail.com | http://www.chicagoteethwhiteningstudio.com/get-to-know-about-melanotan/ |

    An essential hotspot for the gathering of spectators that makes the peruser walk by step.

  21. Roku.com/link manufactures a variety of digital media players that allow customers to access Internet streamed video or audio services through televisions, including subscription-based services as well as services that are available through the receiver free of charge.


  22. Roku.com/link provides the simplest way to stream entertainment to your TV. On your terms. Visit roku.com/link for Roku code linking to your Account.

  23. twitch.tv/activate - Enter the code given to you by your device to link it to your Twitch account. Activate Your Twitch TV with us

  24. You're so cool! I don't think I've read through anything like that before. So great to discover someone with a few original thoughts on this subject matter. Really.. many thanks for starting this up. This site is something that is required on the internet, someone with some originality! <a href="http://...ot;>Gta 5 hack</a>

  25. It is nice to read such high-quality content. It is a good article that discusses the topic at hand quite well. I am looking forward to read more articles from your site. Keep up the good work. Our assignment help experts could address students' academic topics quite well. Thus, they can opt for our service if they have difficulty in writing the academic task.

  26. The blog has a to an extraordinary degree restrain focus that opens up, shockingly into broad assortment of concerns.

  27. Assingnme... | Accounting Assignment Help from Professionals |

    This is a very well written post, my compliments. I’m glad to find your post. Keep sharing this type of stuff.

  28. Each word written has captivated its audience in the most unique way.

  29. Flawless and legendary blog, Full of sublime and virtuosic words.

  30. Writing a blog is a bit of craftsmanship and the essayist has without a doubt aced this aptitude.

  31. Norton.com/setup can be downloaded from the official website of Norton. Norton is a powerful antivirus which is popular for its potential protection against online security risks and threats. There are spywares, adware, worms and viruses which can enter your computer system through the internet. There is a definite use of antivirus in protecting your computer system. Call on Norton customer support number for getting online technical assistance.
    Norton has the complete set of features which is useful in protecting your digital presence and your computing devices. It provides the stability of your computer system. It increases the speed with a PC optimization tool which is inbuilt.
    Before getting started with Norton.com/setup, we should make sure that
    Operating system has latest updates.
    Any other antivirus is not installed on your PC.
    Temporary folders do not contain junk files.
    You have a valid subscription available for Norton.
    http://...n-com-nu16
    http://....com/login
    http://...upkey.com/
    http://...om/install
    norton com setup
    manage norton com
    norton com setup login
    www norton com nu16
    go to norton com setup
    norton setup activate
    norton setup with product code
    norton nu16 product key
    norton com nu16
    Norton SetUp Activation login
    norton antivirus setup assistant
    Norton setup assistant

  32. Microsoft hasn't already introduced any press occasions for such a device, as well as though the business went to the CES 2017 tradeshow in Las Las vega in January 2017, there was no Surface area Phone announcement. Rumour has it that the Microsoft Surface Phone will certainly be readily available in three distinctive versions. In 2015, Microsoft presented Continuum, which allowed phone users connect their devices right into a monitor and key-board as well as get a Windows experience just like the one appreciated by desktop computer customers. Currently, Microsoft has to release a perfect phone that could transform already spent iphone and Android users to Windows. Ideally, this two-year-long news space in the mobile phone market is the result of Microsoft functioning like heck making something new. HTC made the most Windows Phones in 2012 holding practically 44% of the total market.

  33. Ryan Cata... | Ryan Cataldo NJ Criminal Record |

    Personally I think overjoyed I discovered the blogs.

  34. Free Communication App by Whatsapp APK. You are here to download the WhatsApp Messenger 2.16.116 apk file for Android 4.0.3 and up.

  35. assignmen... | assignment help online |

    Congrats on having such well managed site! It has good looks and contains informative content as well. We are also a web portal where students get the help with the academic writing by opting for our assignment help online and can get a well written assignment.

  36. Our website is No. 1 in UK for Assignment Help. You can also hire us Thesis writing in UK, Dissertation writing and other Assignment Writing Services and Help.

  37. I am very happy to read this. This is the kind of manual that needs to be given and not the random misinformation that's at the other blogs. Appreciate your sharing this best posting.....

  38. Your ability to express your thoughts and ideas more clearly is very impressive. Your blog helped me to get more good writing skills. Thank you so much for this helpful post. Keep sharing such wonderful posts. I will always follow your blog.

  39. furukoo | Silverlight VS Flash |

    L'interêt de Silverlight :
    - les outils de developpement sont gratuit.
    Voir Visual Web Developpement Express Edition

    Il accepte 3 languages :
    - Visual Basic
    - C#
    - JavaScript

    (voir un exemple d'application ici : -> www.furukoo.fr)

  40. Dubitatif | Pourquoi Silverlight ? |

    Je ne vois pas trop l'intérêt de Silverlight par rapport à Flash qui est déjà très bien...