mercredi 10 septembre 2008
FAQ Silverlight
lundi 4 août 2008
Read web.config parameters from a Silverlight application
Silverlight is an RIA so the application only live on the client side. Sometime it's a good idea to store parameters on the web.config file (i.e a web service endpoint).
Of course it's impossible to read the configuration file directly from the application running on the client.
What's the workaround ?
The Silverlight application is host on an aspx page in a
string _baseUrl = ConfigurationManager.AppSettings["EndPointAdress"];
After you must give this parameters to the Silverlight asp.net control, you can do that via his InitParameters property :
SLControl.InitParameters = "EndPointAdress=" + _baseUrl;
private void Application_Startup(object sender, StartupEventArgs e)
{
string _baseUrl = e.InitParams["BaseUrl"];
}
That's all ! :)
lundi 21 juillet 2008
Silverlight : Se connecter à une base de données grâce à Linq et WCF
Lire la suite ...
jeudi 17 juillet 2008
Découvrez les trois premiers chapitres du livre intitulé « Introducing Microsoft® Silverlight™ 2, Second Edition »
Microsoft Press vient de sortir un livre sur Silverlight 2. Vous pouvez télécharger sur mon blog les trois premiers chapitres en format PDF. ça se trouve ici
Attention : Ce fichier ne peut pas être redistribué sans mentionner le site du livre : http://www.microsoft.com/MSPress/books/12086.aspx
Lire des paramètres du fichier Web.config depuis une application Silverlight
Silverlight est un RIA, les applications n' existent donc que du coté client. Pourtant parfois il pourrait être pratique de stocker certaines informations dans le fichier web.config du site (par exemple l' adresse d' un service web).
Il est biensur impossible de lire le fichier de configuration se trouvant sur le serveur depuis l' application Silverlight se trouvant elle sur la machine du cliente.
Comment contourner ce problème ?
L'application Silverlight est hostée sur une page aspx dans un contrôlé
string _baseUrl = ConfigurationManager.AppSettings["EndPointAdress"];
Ensuite il faut passer ce paramètre au contrôle Silverlight, cela peut se faire via sa propriété InitParameters :
SLControl.InitParameters = "EndPointAdress=" + _baseUrl;
Dernière étape : récupérer le paramètre dans l' application Silverlight. Cela doit se faire dans le fichier App.xaml.cs dans la méthode Application_Startup
private void Application_Startup(object sender, StartupEventArgs e)
{
string _baseUrl = e.InitParams["BaseUrl"];
}
Voila :) c' était pas plus compliqué que ça ...
lundi 9 juin 2008
Silverlight 2 beta 2
http://www.microsoft.com/downloads/details.aspx?FamilyId=50A9EC01-267B-4521-B7D7-C0DBA8866434&displaylang=en
Si vous avez un projet développé en version 2 beta 1, un conseil faites un backup avant d'installer la beta 2 car la conversion automatique est plus que douteuse...
mardi 20 mai 2008
Coach Silverlight
http://msdn.microsoft.com/fr-fr/silverlight/cc511510.aspx
lundi 19 mai 2008
Comment utiliser un service WCF depuis Silverlight
mardi 22 janvier 2008
Insérer du Flash dans une animation Silverlight (Workaround)
Pour un futur projet je serai amené à développer des animations Silverlight contenant des fichiers flash (swf).
Il semble qu'il n'existe actuellement aucun contrôle Silverlight permettant d'insérer une animation flash.
Voici donc le workaround que j'ai trouvé pour contourner cette "limitation".
Tout d'abord il faut modifier le fichier javascript utilisé pour créer l'objet javascript et ajouter le paramètre isWindowless
Silverlight.createObjectEx({ source: "Page.xaml", parentElement: document.getElementById("silverlightControlHost"), id: controlID, properties: { width: "100%", height: "100%", version: "1.1", isWindowless:"true" }, events: { onError: function(sender, args) { var errorDiv = document.getElementById("errorLocation"); if (errorDiv != null) { var errorText = args.errorType + "- " + args.errorMessage; if (args.ErrorType == "ParserError") { errorText += "
File: " + args.xamlFile; errorText += ", line " + args.lineNumber; errorText += " character " + args.charPosition; } else if (args.ErrorType == "RuntimeError") { errorText += "
line " + args.lineNumber; errorText += " character " + args.charPosition; } errorDiv.innerHTML = errorText; } } } });
Ensuite il faut modifier la page qui contient l'animation silverlight et utiliser la notion de "calque" DHTML grâce au positionnement absolu des contrôles et à une iFrame.
L'iFrame contiendra une page qui contient elle-même le controle flash :
Au final l'iFrame viendra se positionner au dessus de l'animation silverlight.
