Dear visitor, thanks for stopping by! If you want, you can follow all updates on Snowball.be via RSS. You can also follow me on Twitter or Facebook. More interesting posts from other Microsoft Regional Directors can be found at The Region.
Gill Cleeren     Efficiency | Events | Silverlight | Slide decks | Speaking     August 27, 2010    

Yesterday, I gave a talk for DotNed.nl, the Dutch usergroup at the Ordina offices in Nieuwegein. 55 people attended the sold-out talk, I hope you enjoyed it. Any feedback is of course welcome via mail.

The talk, Building an end-to-end Silverlight application consisted out of 10 topics that we often encounter when building LOB applications:

  • 1.SketchFlow
  • 2.WCF RIA Services
  • 3.Data binding & DataGrid
  • 4.MVVM
  • 5.MEF
  • 6.Commanding & behaviors
  • 7.Messaging, navigation & dialogs
  • 8.Custom controls & third party controls
  • 9.OOB
  • 10.Printing

The ZIP file below contains the PPTX and the demos (also of the 2 topics we didn’t cover).

Remember that in 2 weeks, on September 14th, I’ll be again in the Netherlands for 2 sessions for SiXin, the Silverlight usergroup. Registration for this event is free and can be done here.

PPTX & demos

  Posted on: Friday, August 27, 2010 9:54:17 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
         
Gill Cleeren     Silverlight     August 1, 2010    

I’ve been writing some guest articles on SilverlightShow.net in the past couple of weeks. The articles give a complete overview of the current situation of performing duplex communication in Silverlight.

Article 1: The duplex story: looking at duplex communication in Silverlight 4 (Part 1): in this article, I’m giving a full overview of the HttpPollingDuplexBinding in Silverlight 4. This binding can be used to create duplex communication over HTTP.

Article 2: The duplex story: looking at duplex communication in Silverlight 4 - Part 2: Using Sockets: in this second part, I’m taking a look at sockets and how to create super-performing, duplex communication with the protocol. I’m taking a look at the changes made in Silverlight 4 as well.

Article 3: The duplex story: looking at duplex communication in Silverlight 4 - Part 3: Using Net.Tcp: in this final part, I’m looking at the newest option that arrived with Silverlight 4.

I hope you enjoy them!

  Posted on: Sunday, August 01, 2010 9:37:27 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
         
Gill Cleeren     .NET 4 | Efficiency | Personal | Silverlight | Speaking | TechEd     July 13, 2010    

Microsoft just announced that all of us can help deciding which sessions will be delivered at Tech-Ed 2010 Berlin. That's a great way of making sure that the contents is what the public wants!

I've ran through the list and 4 of my proposals made the shortlist (which is good news :)).

  • Treasures for the C# developer in Visual Studio 2010
  • AJAX Tips and tricks: things you never knew that could be done in ASP.NET Ajax
  • Silverlight data access and services not for the faint of heart
  • The good, the bad and… well, that’s it: Comparing good and bad practices in Silverlight application development

If you would like me to deliver one of these sessions on the upcoming Tech-Ed, please vote for them at http://europe.msteched.com/sessionpreference . Of course, there are many really other interesting sessions there as well: I'm sure this will be a great conference!

Thanks for voting!

  Posted on: Tuesday, July 13, 2010 11:37:55 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
         
Gill Cleeren     ASP.net | Events | ppt | Silverlight     June 28, 2010    

Last week, I gave 2 sessions at NDC 2010 (Norwegian Developer Conference) in Oslo. I was glad that I was asked by the organization to be part of this conference that is known for its long list of renowned speakers. Here are my impressions of the conference as well as the downloads I promised in my sessions.

ndc2010

Conference report
Oslo is a really nice city. I mean really nice. People are friendly, the city is very clean and apparently, it houses a lot of great developers too.

NDC 2010 took place this year from June 16th until June 18th in the Oslo Spectrum. The Spectrum is a large event center, comparable to the Sportpaleis in Belgium. For me, it was the first time I’ve been to a conference that was organized in this type of center. I was at first wondering whether this would be handy to attend and give sessions in. Well, it works great ?. You have a great view of the session contents because of the screens being high in the rooms while you can still see the speaker very good as well. While giving my sessions, I was still able to have interaction with and see the audience.  The organization of the event itself was done as it should as well. So for the conference and infrastructure, a big thumbs up!

While infrastructure is one thing, content of sessions is much more important. One of the reasons I was really looking forward coming to this event as a speaker, as I mentioned in the intro, is that it is filled with top speakers for a developer audience Also, I got to hang out with a great number of fellow RDs. Names included Juval Löwy, Michelle Bustamente, Ingo Rammer, Richard Campbell, Carl Franklin, Tim Heuer, Billy Hollis, Rob Conery, Greg Young, Robert Martin and I’m forgetting a whole lot at this point. This is a formula for success: the Norwegians surely know how to “entertain” a developer crowd.

All in all, NDC is a really nice conference that is now on my list of yearly-must-attend events! Congrats on job well done to the people of Programutvikeling (I hope I’m spelling it right, my Norwegian is even after a week still horrible).

Session downloads
Here are the links for downloads for both my sessions:
Silverlight 4 Data Access and Services not for the faint of heart

ASP.NET 4 Caching: Performance for free


If you have any questions or remarks, please send me a mail!

  Posted on: Monday, June 28, 2010 11:18:35 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
         
Gill Cleeren     .NET 4 | Book | Efficiency | Silverlight | sl4     May 22, 2010    

With my book I wrote together with Kevin Dockx, Microsoft Silverlight 4 Data and Services Cookbook available for a couple of weeks now, I decided to do a small search on reviews. I’ll be honest, I took all I could find right now.

9843_Mockupcover

Here’s the ones I found:

Richard Costall:

“Microsoft Silverlight 4 Data and Services Cookbook is a great publication, and worthy of a place any Silverlight developers bookshelf. The formula of ‘recipes’ works well, with well explained, yet simple examples covering almost everything you’d ask when starting out building business applications in Silverlight. It highlights Silverlight 2 and Silverlight 3 functionality differences, yet is right up to date on Silverlight 4.”

Complete review at: http://www.nxtgenug.net/Article.aspx?ArticleID=368

Vikram Pendse writes:

“My Review Comments : * * * * * (5 Stars)..Simple Amazing book !..Go and Grab your Copy Today !!! :)

Impressed with this Book?..want to have a look at? Ok ! What you see is what you get ! kidding..You can download a sample chapter right away !”

Complete review at http://pendsevikram.blogspot.com/2010/05/microsoft-silverlight-4-data-and.html

Damir Tomicic writes:

“Das Buch ist sehr praktisch geschrieben. Der Leser merkt sofort, dass Gill und Kevin die Ansätze selbst ausprobiert und für die Leser optimiert haben. Die gewählte Sprache ist einfach, die Beispiele auch für Anfänger geeignet. Ein guter Einstieg in das Thema.”

Complete review at: http://tomicic.de/2010/05/05/MicrosoftSilverlight4DataAndServicesCookbookGillcleeren.aspx

Review on Amazon.com

“Good Introduction to the Datagrid, Dataform, and different Services (4/5)”


Complete review at http://www.amazon.com/Microsoft-Silverlight-Data-Services-Cookbook/product-reviews/1847199844/ref=dp_db_cm_cr_acr_txt?ie=UTF8&showViewpoints=1

Interested in my book as well? It is available from Packt Publishing, Amazon.com, Amazon UK and many other retailers as well! I hope you enjoy it!

  Posted on: Saturday, May 22, 2010 10:06:33 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
         
Gill Cleeren     Efficiency | Silverlight | sl4     April 26, 2010    

Earlier today, I got confirmation that my first book I wrote (together with Kevin Dockx) has been published and can now be ordered, both in e-book and hard copy. This is the new cover. The book also marks the launch of the new brand of Packt, namely Packt Enterprise.

9843_Mockupcover

The e-book version is available from the publisher’s website: https://www.packtpub.com/microsoft-silverlight-4-data-and-services-cookbook/book . On this site, you can also get a discount on the printed version.

You can also buy the book from Amazon of course (which at this moment still lists it as pre-order though). If you shop at Amazon.com, you can get your copy here: http://www.amazon.com/Microsoft-Silverlight-Data-Services-Cookbook/dp/1847199844. If you rather order at Amazon UK, you can order here: http://www.amazon.co.uk/Microsoft-Silverlight-Data-Services-Cookbook/dp/1847199844/ref=sr_1_1?ie=UTF8&s=books&qid=1272289229&sr=8-1.

If you want to get a more in-depth look at what the book has to offer, take a look here: https://www.packtpub.com/microsoft-silverlight-4-data-and-services-cookbook/book#in_detail .

What the book is about:

Silverlight 3 made a big step into Line-Of-Business applications and Silverlight 4 builds further on this. This book is not a general Silverlight 4 overview book; it is uniquely aimed at developers who want to build data-driven applications using Silverlight. It focuses on showing . NET developers how to interact with and handle multiple sources of data in Silverlight business applications and how to solve particular data problems, following a practical hands-on approach, using real-world recipes in a practical cookbook format. The book is aimed at Silverlight 4, however most of the covered features work both in Silverlight 3 and 4.

By following the practical recipes in this book, you will learn the concepts needed to create data-rich business applications—from the basic creation of a Silverlight application, to displaying data using data binding and upgrading your existing applications to use Silverlight.

Who this book is written for:

If you are a .NET developer who wants to build professional data-driven applications with Silverlight, then this book is for you. Basic Silverlight experience and familiarity with accessing data using ADO.NET in regular .NET applications is required.

What you will learn from this book:

  • Display and validate data efficiently in Silverlight business applications using data binding
  • Use the full power of the important data controls in Silverlight such as the DataGrid and the DataForm
  • Discover how your Silverlight business applications can quickly access data residing in a database or even Windows Azure by calling web services using XML, RSS, JSON and more
  • Exchange information between Silverlight clients and WCF or ASMX services in your Silverlight business applications
  • Add functionality to your Silverlight business applications by harnessing REST and WCF Data Services
  • Communicate with well-known REST APIs such as Flickr and Twitter from Silverlight
  • Simplify your data-driven business application development with WCF RIA Services

You can also read some sample recipes on the Packt site here: https://www.packtpub.com/article/inserting-updating-deleting-sorting-grouping-displaying-data-grid-silverlight .

I do hope you’ll like the book. If you have any questions on the book, don’t hesitate to mail me at silverlight@snowball.be .

  Posted on: Monday, April 26, 2010 4:32:01 PM (Romance Daylight Time, UTC+02:00)   |   Comments [3]
         
Gill Cleeren     .net | .NET 4 | C# | Silverlight | sl4 | VS2010     April 12, 2010    

After beta’s and one RC release, starting today, we can get our hands on Visual Studio 2010 RTM. Just hours ago, Microsoft held a keynote on the release of their flagship IDE, Visual Studio 2010. This release coincides with the release of .NET 4.0 and of course Silverlight 4, which has its official launch event tomorrow. This marks probably the largest release ever for developers from Microsoft.

 image

I need it badly

Visual Studio 2010 is like honey, developers swarm to it. It’s understandable that you want to get your hands on the bits. Where can you get them?
If you’re an MSDN subscriber, you’re in luck, as you can get all the bits from the MSDN subscription site. (http://msdn.microsoft.com/subscriptions)
If you are not, you have the following options:

image

 

Why you need it

If I wanted to make a list of reasons why you should be upgrading to Visual Studio 2010, I would be up all night I think. Since it’s quite late already, I’m going to make an all-but-complete list with my top features that make Visual Studio 2010 an not-to-miss upgrade. (For the complete list – you’re warned, it’s very complete – take a look here: http://msdn.microsoft.com/en-us/library/bb386063(VS.100).aspx)

The IDE looks really stylish!

Upon opening Visual Studio 2010 for the first time, you’ll immediately notice that something happened… Something big. No longer the traditional grey interface, but an exciting new look for the place you spend all your development hours in. Built entirely in WPF, the new shell offers plenty of extension points so you can make it feel even more like home.

image

New IDE features

I personally like the Navigate To function a lot (I blogged about it yesterday here: Visual Studio 2010 Tip- Navigate to functionality). Another one I like is the zoom in/out we can now do in the code editor. This is a real life-saver when doing demos on stage or when showing someone some code. Simply keep CTRL key pressed and rotate that mouse wheel of yours. For people who work on multiple monitors, Visual Studio now supports this much better!

Some other nice features:

  • Improved IntelliSense
  • Highlight references
  • Stub generation

New framework and languages

Visual Studio 2010 comes packed with new releases.

  • Silverlight 4 :) More on this at the launch event tomorrow!
  • C# 4.0 adds interesting new features to the language (more here). Also VB.net developers aren’t left outside in the cold, their favorite language gets an upgrade as well to Visual Basic 2010.
  • ASP.NET 4.0 as well as MVC 2 are born! If you want to get an overview of what’s new, download my talk of DevDays 2010 here. Most striking new features in WebForms 4 are client IDs, control over ViewState and more control over the HTML that’s being rendered.
  • Entity Framework makes a jump and goes straight to v4.
  • WCF and WF both get an upgrade to v4 as well.
  • TFS installation gets really simple using TFS Basic.
  • F# is now available for the functional programming needs.
  • SharePoint templates!

I want more

Not enough reading material for your brain? A free ebook is made available “Moving to Visual Studio 2010” here.

Warnings here!

Something to watch out for: currently, the Windows Phone 7 tools do not work with the RTM version of 2010. Read more on this here: http://forums.silverlight.net/forums/t/175181.aspx 

image

  Posted on: Monday, April 12, 2010 11:54:13 PM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
         
Gill Cleeren     .NET 4 | Events | Silverlight | sl4 | Slide decks     April 4, 2010    

Overlapping with the Dutch DevDays event this year, I was of course present at TechDays 2010 Belgium as well. TechDays really became a big event with lots of attendees, speakers and sponsors. Never before had the line-up of speakers been so impressive, with names such as Anders Hejlsberg, Scott Hanselman, Charley Kindel… The feedback that I’ve heard was very positive, with the general comment being that the session content was good, deep dive and well brought by the speakers.

I got 2 session slots:

  • Silverlight 4 Tour de Force with a little WPF 4 sauce on top (together with Katrien De Graeve)
  • Building Data-Driven applications FAST with RIA services and Silverlight

As promised during the talks, I have uploaded all slide decks and demos for both sessions below. You can download them and use them as you like.

  • Silverlight 4 Tour de Force with a little WPF 4 sauce on top
  • Building Data-Driven applications FAST with RIA services and Silverlight

I took some pictures during the event as well. Below I posted some, the entire set can be seen here.

IMG_0079 IMG_0106 IMG_0083

IMG_0095 IMG_0104 IMG_0092

  Posted on: Sunday, April 04, 2010 5:06:40 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
         
Gill Cleeren     Efficiency | Silverlight     March 15, 2010    

I just noticed now that Silverlight 4 officially hit RC, that the book I wrote (together with Kevin Dockx) is now featured on Silverlight.net: http://www.silverlight.net/learn/books/ . Really cool to be on that site!!

  Posted on: Tuesday, March 16, 2010 12:08:12 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     Silverlight | Speaking     March 8, 2010    

In the coming weeks and months, I’ll be presenting at several conferences. In April, I’m booked to give a talk on Silverlight 4 and WPF 4 in Birmingham for VBUG’s Spring Conference 2010. You can find the full agenda here: http://www.vbug.co.uk/

The event takes place at Heritage Motor Centre on Thursday April 29th 2010.

About the conference:

With the imminent release of Microsoft Visual Studio 2010 and the .Net framework 4, 'VBUG4Thought' celebrates and highlights these new products.
This conference is ideal if you wish to learn about the new enhancements, features and capabilities of VS2010 and .Net 4. The conference will also give you an overview of how you can apply these technologies in new or exisiting projects.
As usual, we'll be featuring key speakers from the UK and abroad in order to give you expert, impartial and informative advice. Hadi Hariri, Jon Skeet, Gill Cleeren, Dave Sussman, Josh Twist and Eric Nelson are confirmed as speakers.

  Posted on: Tuesday, March 09, 2010 12:03:47 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     Azure | Case studies | Microsoft | Silverlight     March 8, 2010    

In my busy time (see previous post), some really interesting case studies were released.

  • On iis.net, a huge white paper was posted on the Sunday Night Football site. This site, which may not be known to European readers as much, is now built entirely on Silverlight 3 backed by IIS Smooth Streaming. The latter, an ability to dynamically adapt the bit rate of the video stream, is unique in a RIA technology: for example Flash does not have this on board. This way, viewers with lower bandwidth or slower PC processors frequently experience long periods of video buffering, stuttering, and degraded picture quality. Silverlight solves this. The white paper can be read at http://learn.iis.net/page.aspx/808/sunday-night-football-live-in-hd-with-microsoft-silverlight-3-and-iis-smooth-streaming/
  • The second interesting case study can be found at http://www.microsoft.com/casestudies/Case_Study_Detail.aspx?CaseStudyID=4000005861%0d . This case describes the use of Windows Azure by Outback Steakhouse. Outback was looking for a social networking presence but did not know what to expect in visitor numbers. Windows Azure offered them exactly what they needed.
  Posted on: Tuesday, March 09, 2010 12:00:00 AM (Romance Standard Time, UTC+01:00)   |   Comments [1]
         
Gill Cleeren     Silverlight | sl4     March 8, 2010    

As many of you may already know, I’m working on a book titled Silverlight 4 Data and Services Cookbook. Writing my first book (together with fellow Silverlight addict Kevin Dockx) has taken a lot of my time, I haven’t been able to blog as much as I used to. My sincere apologies for that :)

The good news is that the book is almost done, we’re in the last straight line to the publication stage! Even more good news is that the book is already available for pre-order at the publisher’s site: http://www.packtpub.com/microsoft-silverlight-4-data-and-services-cookbook/book .

1847199844

The contents of the books is the following:

Over 85 practical recipes for creating rich, data-driven business applications in Silverlight

  • Design and develop rich data-driven business applications in Silverlight
  • Rapidly interact with and handle multiple sources of data and services within Silverlight business applications
  • Understand sophisticated data access techniques in your Silverlight business applications by binding data to Silverlight controls, validating data in Silverlight, getting data from services into Silverlight applications and much more!
  • Packed with practical, hands-on cookbook recipes, illustrating the techniques to solve particular data problems effectively within your Silverlight business applications

In detail:

Microsoft Silverlight is a programmable web browser plugin that enables features including animation, vector graphics, and audio-video playback – features that characterize Rich Internet Applications. However, Silverlight is a great (and growing) Line-Of-Business platform and is increasingly being used to build data-driven business applications. Silverlight Data Services enable efficient access to your data, allowing you to draw on multiple sources of data and solve particular data problems. There is very little existing material that demonstrates how to build data-driven solutions with the platform. Silverlight 3 made a big step into Line-Of-Business data services and Silverlight 4 builds further upon this. This book will enable .NET developers to get their finger on the pulse of data-driven business applications in Silverlight.

This book is not a general Silverlight 3/4 overview book; it is uniquely aimed at developers who want to build data-driven applications. It focuses on showing .NET developers how to interact with, and handle multiple sources of data in Silverlight business applications, and how to solve particular data problems following a practical hands-on approach, using real-world recipes. It is a practical cookbook that teaches you how to build data-rich business applications with Silverlight that draw on multiple sources of data. Most of the covered features work both in Silverlight 3 and 4. However, we cover some that are specific for Silverlight 4, which will therefore not work with Silverlight 3. Where this is the case, it is clearly indicated.

Packed with reusable, real-world recipes, the book begins by introducing you to general principles when programming Silverlight. It then dives deep into the world of data services, covering all the options available to access data and communicate with services to get the most out of data in your Silverlight business applications, whilst at the same time providing a rich user experience. Chapters cover data binding, data controls, the concepts of talking to services, communicating with WCF, ASMX and REST services, and much more.

By following the practical recipes in this book, which are of varying difficulty levels, you will learn the concepts needed to create data-rich business applications—from the creation of a Silverlight application, to displaying data in the Silverlight application and upgrading your existing applications to use Silverlight. Each recipe covers a data services topic, going from the description of the problem, through a conceptual solution to a solution containing sample code.

I’m really really excited about the upcoming release, I hope you enjoy reading it as much as I did writing it! As you can see, the book takes a very practical approach to working with Silverlight in enterprise environments using a recipe-approach. The scenarios for these recipes are things me an you often encounter and this book should give you the solution for them. The book is aimed at Silverlight 4 development, although most recipes will work in Silverlight 3 as well.

I hope in the coming weeks/months to be able to give away a few copies of the book from here.

  Posted on: Monday, March 08, 2010 11:31:07 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 23, 2009    

Yes, I made it :) Welcome to this last post in my Silverlight Advent Calendar! From December 1st until today, December 24th, I have created each day, a Silverlight article. When I first thought about it, I feared there would be at least one day I would not be able to create my post. Well, this didn’t happen, and this means that after 24 articles, we have finally arrived at Christmas Eve. I really hope you enjoyed these posts and I’ll sure be doing something similar in the future!

On a “real” advent calendar, on December 24th, the final day of the calendar, you get a special surprise: a bigger image, a bigger gift or a larger chunk of chocolate than on other days. Well, I thought this needed to be the case in my advent calendar as well, so I decided to end my series with a special post. It gives a preview of something that can in much more detail be found in my upcoming book AND it brings some more Christmas spirit on this day: a Flickr Christmas image browser. All free as my gift to you!

Below is the interface of the application.

image

We’re in luck when working with Flickr: it exposes a cross-domain file so we can access their API services from a client Silverlight application, even without running with elevated permissions! Therefore, we do not need to create a service layer that sits in between our application and Flickr’s services.

When clicking on the Get Pictures button, we load thumbnails into a templated StackPanel. When clicking on any of these thumbnails, the large image is loaded. To store the information needed for a thumbnail, I created a class called SmallFlickrImage.

public class SmallFlickrImage
{
  public string ImageId { get; set; }
  public string FarmId { get; set; }
  public string ServerId { get; set; }
  public string Secret { get; set; }
 
  public string ImageUrl
  {
    get
    {
      return string.Format(
        "http://farm{0}.static.flickr.com/{1}/{2}_{3}_m.jpg", 
        FarmId, 
        ServerId, 
        ImageId, 
        Secret
        );
    }
  }
}

In the click event, we perform a service call to Flickr. To call Flickr’s API, you’ll need an API key which can be obtained for free at http://www.flickr.com/services/api/. Once obtained, you need to embed this key in each request your application will perform with Flickr. Also on this site, you’ll find a complete overview of all available methods. Here, I’m using the flickr.photos.search method, which accepts a search string and returns me an XML response, containing all the information I need to display images in my client side application.

Working with Flickr is a typical example of a REST service. When working with these services from Silverlight, we actually need to do 3 steps:

  • Create a URL
  • Send a request to this URL
  • Accept the response, mostly in XML, sometimes in JSON

The URL is constructed as follows (as directed by Flickr):

string searchUrl = 
  "http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key={0}
   &text=christmas tree snow";

To send a request to this URL, we can use either the WebClient, or the HttpWebRequest. WebClient is sufficient (there are cases where this is not the case, I spent many pages to this topic in my book ;) ). Working in Silverlight with WebClient is identical to working with this class in the full .NET framework. One thing though: just like any interaction with a service, the service call is to be done asynchronously. The code below sends a request to Flickr:

private void GetPicturesButton_Click(object sender, RoutedEventArgs e)
{
    WebClient client = new WebClient();
    client.DownloadStringCompleted += 
      new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
    client.DownloadStringAsync(new Uri(string.Format(searchUrl, api_key)));
}

In the callback, which is invoked automatically when the service returns, using some very simple LINQ-To-XML, we can parse the results. The returned XML is always of the same format and can be seen as the contract between Flickr and my application. Because we cannot set the Source property of an Image control directly, we need to go around using a BitmapImage.

protected void client_DownloadStringCompleted(object sender, 
  DownloadStringCompletedEventArgs e)
{
  XDocument xml = XDocument.Parse(e.Result);
 
  var photos = from results in xml.Descendants("photo")
               select new SmallFlickrImage
               {
                 ImageId = results.Attribute("id").Value.ToString(),
                 FarmId = results.Attribute("farm").Value.ToString(),
                 ServerId = results.Attribute("server").Value.ToString(),
                 Secret = results.Attribute("secret").Value.ToString()
               };
 
  foreach (var photo in photos)
  {
    Image image = new Image();
 
    BitmapImage bitmapImage = new BitmapImage(new Uri(photo.ImageUrl, UriKind.Absolute));
    image.Source = bitmapImage;
    image.Width = 160;
    image.Height = 160;
    image.Stretch = Stretch.Uniform;
    image.Tag = photo;
    image.Margin = new Thickness(3);
    image.HorizontalAlignment = HorizontalAlignment.Center;
    image.MouseLeftButtonDown += new MouseButtonEventHandler(img_MouseLeftButtonDown);
    PicListBox.Items.Add(image);
  }
}

At this point, the ListBox is filled. This ListBox is templated; the code for this can be seen in the sample code download.

When clicking (we attached a MouseLeftButtonDown event on each dynamically added image) on an image, we’ll load the "full” image into an Image control. This requires some code, mostly concerning which type of URL is used by Flickr for the image.

void img_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
  Image img = sender as Image;
  SmallFlickrImage smallFlickrImage = img.Tag as SmallFlickrImage;
  if (smallFlickrImage != null)
  {
    WebClient detailClient = new WebClient();
    detailClient.DownloadStringCompleted += 
      new DownloadStringCompletedEventHandler(detailClient_DownloadStringCompleted);
    detailClient.DownloadStringAsync(
      new Uri(string.Format(detailUrl, api_key, smallFlickrImage.ImageId)));
  }
}
 
void detailClient_DownloadStringCompleted(object sender, 
  DownloadStringCompletedEventArgs e)
{
  XDocument xmlDocument = XDocument.Parse(e.Result);
  XElement photoElement;
  Uri detailImageUrl;
 
  if (xmlDocument.Descendants("photo").Count<XElement>() > 0)
  {
    photoElement = xmlDocument.Descendants("photo").First<XElement>();
 
    string serverId = photoElement.Attribute("server").Value;
    string farmId = photoElement.Attribute("farm").Value;
    string imageId = photoElement.Attribute("id").Value;
    string secret;
    
    if (photoElement.Attribute("originalsecret") != null)
    {
      secret = photoElement.Attribute("originalsecret").Value;
      detailImageUrl = new Uri(string.Format
        ("http://farm{0}.static.flickr.com/{1}/{2}_{3}_o.jpg", 
          farmId, 
          serverId, 
          imageId, 
          secret)
         );
    }
    else
    {
      secret = photoElement.Attribute("secret").Value;
      detailImageUrl = new Uri(string.Format
        ("http://farm{0}.static.flickr.com/{1}/{2}_{3}.jpg", 
          farmId, 
          serverId, 
          imageId, 
          secret)
         );
    }
 
    BitmapImage bitmapImage = new BitmapImage(detailImageUrl);
    DetailImage.Source = bitmapImage;
  }
}

 

With that, the sample is working!

The complete code sample can be downloaded here: SLChristmasFlickr.zip (31.34 KB)

MERRY CHRISTMAS!

  Posted on: Thursday, December 24, 2009 12:50:15 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 20, 2009    

In the before-last post of my Silverlight Advent Calendar, I would like to spend some time with a Silverlight 3 feature that’s most helpful in real world projects: merged resource dictionaries. By most helpful, I mean that in real applications, resource files can become really really big. Files of 1000 lines of pure mark-up are no exception and are really hard to find your way in.

Silverlight 3 added support for merged dictionaries. Basically, using these, we can split resources over several files, dictionaries. Using them though is nothing different than using resources located in App.xaml or Resources of the current page/control.

Let’s take a look at using these merged resource dictionaries. I created some styles to style the ChristmasSong application we have been using a few times already.

 

image

In the beginning of this series, we already looked at implicit styles. For this application, I’m defining a few of these, meaning that this very project will only work for Silverlight 4. Of course, the merged dictionary function works also in Silverlight 3.

To define a resource dictionary, in the project, we need to add a XAML file (either via creating an empty text file and renaming the extension or creating a new user control and deleting the *.cs file). In this file, we can create a ResourceDictionary element. Below is the XAML code for the implicit styles, which I grouped into a file called DefaultStyles.xaml. I created a default style for a Button, TextBlock and TextBox.

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="Button">
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="Background" Value="Red" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="HorizontalAlignment" Value="Center"></Setter>
        <Setter Property="VerticalAlignment" Value="Center"></Setter>
    </Style>
 
    <Style TargetType="TextBlock">
        <Setter Property="Foreground" Value="Green" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="HorizontalAlignment" Value="Left"></Setter>
        <Setter Property="VerticalAlignment" Value="Center"></Setter>
        <Setter Property="Margin" Value="2"></Setter>
    </Style>
 
    <Style TargetType="TextBox">
        <Setter Property="Width" Value="150" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="HorizontalAlignment" Value="Center"></Setter>
        <Setter Property="VerticalAlignment" Value="Center"></Setter>
        <Setter Property="Margin" Value="2"></Setter>
    </Style>
</ResourceDictionary>

Next, I created a second ResourceDictionary which has just one Style, designed for the title, in a file called SpecificStyles.

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="TextBlock" x:Key="TitleStyle">
        <Setter Property="Foreground" Value="Red" />
        <Setter Property="FontStyle" Value="Italic"></Setter>
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontSize" Value="28" />
        <Setter Property="HorizontalAlignment" Value="Center"></Setter>
        <Setter Property="VerticalAlignment" Value="Center"></Setter>
    </Style>
</ResourceDictionary>

Now we need to let our application know about these resources. To do so, I have in the App.xaml added the following code. In the MergedDictionaries element, we link the seperate XAML files.

<Application 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  x:Class="SLMergedDictionaries.App"
  >
  <Application.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary 
          Source="/SLMergedDictionaries;component/DefaultStyles.xaml">
        </ResourceDictionary>
        <ResourceDictionary 
          Source="/SLMergedDictionaries;component/SpecificStyles.xaml">
        </ResourceDictionary>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Application.Resources>
</Application>

We can now use the styles declared in the dictionaries just like we would do with regular defined styles.

The complete sample can be downloaded here: SLMergedDictionaries.zip (310.39 KB)

  Posted on: Monday, December 21, 2009 12:46:11 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 20, 2009    

Next to the full support of the data binding engine for the IDataErrorInfo interface, Silverlight 4 adds a new interface called INotifyDataErrorInfo, offering more options for particular scenario's. In this post, we’ll look at a small example using this interface.

IDataErrorInfo allows retrieving the error on a per-property basis. It’s not possible however to validate all properties of the entity in one go. This becomes possible with the INotifyDataErrorInfo. Let’s look at the interface first.

public interface INotifyDataErrorInfo
{
    bool HasErrors { get; }
 
    event EventHandler ErrorsChanged;
 
    IEnumerable GetErrors(
                    string propertyName);
}

This interface has some nice advantages. As said, we can check if the entity as a whole is in an invalid state through the HasErrors property. Retrieving the errors using the GetErrors can now retrieve other things than just strings which was all that we could do with the IDataErrorInfo. On top of that, a property can have more than just one validation error at the same time

The ErrorsChanged event can come in handy if there’s a long running process needed to perform validation: assume that for some validation, we need to go to the database over a service. The ErrorsChanged event allows us to notify the UI if the validation errors change. If ValidatesOnNotifyDataErrors is set to true on the UI, Silverlight will listen for the ErrorsChanged event and will display any errors if they are added afterwards.

That’s it for this interface, let’s now look at it in an example. I have changed the example created for the IDataErrorInfo to work with INotifyDataErrorInfo, so the interface has remained the same.

The errors I want to return to my interface are more than just strings. I created a custom error as follows:

public class ChristmasSongError
{
    public ErrorLevel Severity{ get; set; }
    public string ErrorName { get; set; }
    public string ErrorMessage { get; set; }
 
    public override string ToString()
    {
        return ErrorName + ": " + ErrorMessage;
    }
}

The ChristmasSong class now implements the INotifyDataErrorInfo interface. Let’s focus on the Title property. When its value is set, it calls a validation method. In this method, I create an instance of the custom error, specifying all the property values. If there’s an error, here the title being empty, I add it to a Dictionary called errors using the AddError method. If validation is satisfied, it’s removed using the RemoveError method. The errrors Dictionary is used so it is possible for each property to have more than one error: each property has as its value a List.

public class ChristmasSong : INotifyDataErrorInfo
{
    private string title;
    private string performedBy;
    private TimeSpan duration;
    private DateTime published;
 
    private string error;
 
    public Dictionary<string, List> errors = 
      new Dictionary<string,List>();
 
    public event PropertyChangedEventHandler PropertyChanged;
 
    protected void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(
                    this, new PropertyChangedEventArgs(propertyName));
    }
 
    public string Title
    {
        get
        {
            return title;
        }
        set
        {
            title = 
                    value;
            ValidateTitleProperty();
        }
    }
 
    private void ValidateTitleProperty()
    {
        ChristmasSongError christmasSongError =
new ChristmasSongError() 
        { Severity = ErrorLevel.Error, ErrorName =
"TitleRequired", 
          ErrorMessage = 
                    "Title should not be empty" };
        if (string.IsNullOrEmpty(title))
        {
            AddError(
                    "Title", christmasSongError);
        }
        else
        {
            RemoveError(
                    "Title", "TitleRequired");
        }
    }
 
    public string PerformedBy
    {
        get
        {
            return performedBy;
        }
        set
        {
            performedBy = 
                    value;
            ValidatePerformedByProperty();
        }
    }
 
    private void ValidatePerformedByProperty()
    {
        ChristmasSongError christmasSongError =
new ChristmasSongError() 
        { Severity = ErrorLevel.Error, ErrorName =
"PerformedByRequired", 
          ErrorMessage = 
                    "The artist should not be empty" };
        if (string.IsNullOrEmpty(performedBy))
        {
            AddError(
                    "PerformedBy", christmasSongError);
        }
        else
        {
            RemoveError(
                    "PerformedBy", "PerformedByRequired");
        }
    }
 
    public TimeSpan Duration
    {
        get
        {
            return duration;
        }
        set
        {
            duration = 
                    value;
            ValidateDuration();
        }
    }
 
    private void ValidateDuration()
    {
        ChristmasSongError durationNullError =
new ChristmasSongError() 
        { Severity = ErrorLevel.CriticalError, ErrorName =
"DurationNull", 
          ErrorMessage = 
                    "The duration should not be empty" };
        ChristmasSongError durationTooLongError =
new ChristmasSongError() 
        { Severity = ErrorLevel.Error, ErrorName =
"DurationTooLong", 
          ErrorMessage = 
                    "The duration is too long" };
        
        if (duration == TimeSpan.Zero)
        {
            AddError(
                    "Duration", durationNullError);
        }
        else
        {
            RemoveError(
                    "Duration", "DurationNull");
        }
 
        if (duration.TotalSeconds > 500)
        {
            AddError(
                    "Duration", durationTooLongError);
        }
        else
        {
            RemoveError(
                    "Duration", "DurationTooLong");
        }
    }
 
    public DateTime Published
    {
        get
        {
            return published;
        }
        set
        {
            published = 
                    value;
            VaidatePublished();
        }
    }
 
    private void VaidatePublished()
    {
        ChristmasSongError publishedTooLow =
new ChristmasSongError() 
        { Severity = ErrorLevel.CriticalError, ErrorName =
"PublishedTooLow", 
          ErrorMessage = 
                    "The date is too small" };
        ChristmasSongError publishedTooHigh =
new ChristmasSongError() 
        { Severity = ErrorLevel.CriticalError, ErrorName =
"PublishedTooHigh", 
          ErrorMessage = 
                    "The date is too high" };
 
        if (published < new DateTime(1900, 1, 1))
        {
            AddError(
                    "Published", publishedTooLow);
        }
        else
        {
            RemoveError(
                    "Published", "PublishedTooLow");
        }
 
        if (published > new DateTime( 2010, 1, 1))
        {
            AddError(
                    "Published", publishedTooHigh);
        }
        else
        {
            RemoveError(
                    "Published", "PublishedTooHigh");
        }
    }
 
    private void AddError(string propertyName, ChristmasSongError error)
    {
        
 
        if (!errors.ContainsKey(propertyName))
        {
            errors.Add(propertyName, 
                    new List() { error });
        }
        else// adding the error to the already existing list
        {
            var list = errors[propertyName];
            list.Add(error);
        }
 
        if (ErrorsChanged != null)
            ErrorsChanged(
                    this, new DataErrorsChangedEventArgs(propertyName));
    }
 
    private void RemoveError(string propertyName, string errorName)
    {
        if (errors.ContainsKey(propertyName))
        {
            var christmasSongError = errors[propertyName]
                .Where
(e => e.ErrorName == errorName).FirstOrDefault();
            var list = errors[propertyName];
            list.Remove(christmasSongError);
 
            if (list.Count == 0)//no more errors for this property 
            {
                errors.Remove(propertyName);
            }
 
            if (ErrorsChanged != null)
                ErrorsChanged(
                    this, new DataErrorsChangedEventArgs(propertyName));
        }
    }
 
    public event EventHandler ErrorsChanged;
 
    public System.Collections.IEnumerable GetErrors(string propertyName)
    {
        if (string.IsNullOrEmpty(propertyName))//retrieve
                        errors for entire entity
        {
            return errors.Values;
        }
        else
        {
            if (errors.ContainsKey(propertyName))
                return errors[propertyName];
            return null;
        }
    }
 
    public bool HasErrors
    {
        get
        {
            if (errors.Count == 0)
                return false;
            return true;
        }
    }
}

With the entity in place, we can look at the UI. The XAML code is similar to the IDataErrorInfo example, although we should now use the ValidatesOnNotifyDataErrors and set it to True. Below is part of the code, for the entire listing, see the download.

<TextBox x:Name="TitleTextBox" Grid.Row="1" Grid.Column="1" Width="200" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2"

Text="{Binding Path=Title,Mode=TwoWay,ValidatesOnNotifyDataErrors=True,NotifyOnValidationError=True}" />

The complete sample can be downloaded here: SLINotifyDataErrorInfo.zip (602.56 KB)

  Posted on: Monday, December 21, 2009 12:42:27 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 20, 2009    

Services and data access are the focus of the book I’m writing (more very very soon!). Working with services to get data into a Silverlight application is so vital, it should be code that’s known by every Silverlight developer by heart. Working with duplex bindings is somewhat more complicated. However, there are situations in which duplex communication is really necessary. Think of the typical example: a stock application that should send stock updates to the client without the client requesting for an update.

Duplex communications are possible with WCF. They “seem” initiated by the server: the service will send updates without the client requests the service to do so. This way, the client can receive updates whenever new information is available on the server (new stock info that becomes available) and act accordingly. I put seem between quotes. The reason for that is that a duplex binding is in fact still a normal request/receive process. Initially, the client has to do a request to the service and from then on, the service can send its updates to the client.

In the example I have created for this post, I created an application that posts updates about snow throughout Belgium (while writing this article, it has snowed quite a lot in Belgium, so that’s where the inspiration came from and Tienen is where I live :) ). Below is a screenshot.

image

Of course, you’re here to learn something and see some code, right? No problem! Let’s first focus on the service. For the data exchange, I created a small type called SnowUpdate.

public class SnowUpdate
{
    public string Location { get; set; }
    public double centimeter { get; set; }
}

One very important thing that we need to do, is adding a reference to an assembly available in the Silverlight SDK called System.Service.PollingDuplex.dll. By default, it’s installed in C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server. Add a reference to this assembly. (Note the x86, that’s because I’m running 64bit).

The contract of the service makes it clear that we are working with a duplex service. There are some special things to note in this code. As you can see, two interfaces are defined here. The first one is the regular contract, the second one is what’s called the callback contract and defines the contract for the call to the client.

Also note that both OperationContracts have IsOneWay set to true. For the Connect method, we’re actually saying: a client can call Connect to make itself known to the service but it expects no response, hence the IsOneWay.

[ServiceContract(Namespace = "Silverlight", CallbackContract = typeof(ISnowServiceClient))]
public interface ISnowService
{
    [OperationContract(IsOneWay = true)]
    void Connect();
}
 
[ServiceContract]
public interface ISnowServiceClient
{
    [OperationContract(IsOneWay = true)]
    void SendSnowUpdate(SnowUpdate snowUpdate);
}

In the service implementation, I have created a Timer, which will periodically send a new message to the client. The OperationContext.Current.GetCallbackChannel gives us access to the callback channel which we can use to send messages to the client side. On a tick of the Timer, we’re sending a message.

private ISnowServiceClient client;
private Timer timer;
 
public void Connect()
{
    client = OperationContext.Current.GetCallbackChannel<ISnowServiceClient>();
    timer = new Timer(new TimerCallback(TimerTick), null, 500, 5000);
}
 
void TimerTick(object state)
{
    try
    {
        if (client != null)
        {
            client.SendSnowUpdate(GetLatestUpdate());
        }
    }
    catch (Exception)
    {
 
        client = null;
        timer.Dispose();
    }
}

With that, the service code is done, but it does require some specific configuration code to work. Take a look at the sample for this code. We can now look at the client code. The process to add a service reference is exactly the same, although you’ll notice that the ServiceReferences.clientconfig file remains empty (which it does not when referencing a normal service). Therefore, the code that we need to write is somewhat more complex: we have to create the binding and the address from code and pass this along with the proxy instantiation. Below you can see the client-side code.

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
  EndpointAddress address = new EndpointAddress("http://localhost:59485/SnowService.svc");
 
  CustomBinding binding = new CustomBinding(
    new PollingDuplexBindingElement(),
    new BinaryMessageEncodingBindingElement(),
    new HttpTransportBindingElement());
  
  client = new SLDuplexSnow.SnowService.SnowServiceClient(binding, address);
 
  client.SendSnowUpdateReceived += 
    new EventHandler<SLDuplexSnow.SnowService.SendSnowUpdateReceivedEventArgs>
     (client_SendSnowUpdateReceived);
    client.ConnectAsync();
}
 
void client_SendSnowUpdateReceived(object sender, 
  SLDuplexSnow.SnowService.SendSnowUpdateReceivedEventArgs e)
{
    SnowDetailsGrid.DataContext = e.snowUpdate;
}

Note that we are calling ConnectAsync to let the service know about the client so it can send updates to it BUT we are handing SnowUpdateReceived events.

NOTE: This sample is written for Silverlight 3/VS2008. At this point, I have issues with VS2010 when generating the client proxy with SL4/VS2010 when using a duplex service.

The complete code can be downloaded here: SLDuplex.zip (111.91 KB)

  Posted on: Monday, December 21, 2009 12:38:33 AM (Romance Standard Time, UTC+01:00)   |   Comments [4]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 19, 2009    

In today’s post, we’ll take a look at Silverlight’s Isolated Storage, a feature already available in Silverlight since version 2. With this post, I want to show all there is possible with this handy option.

We all know cookies, small text files that are stored on our machines by sites. Most of the time, the goal of a cookie, is storing informational data for next visits of the user to that particular site. This data can vary from login information to perhaps a background color the user favors. Cookies are limited to containing just plain text as well as in size.

Isolated storage does not differ that much from cookies. It’s basically a file store for Silverlight: Silverlight applications can store in the Isolated Storage files during a session and retrieve them in a later session. Isolated storage is a per-user per-application storage, meaning that when userA works with SilverlightAppA, he’ll have a different isolated storage from userB working with the same application. Isolated storage information is not deleted when you clear your temporary internet files, it can be deleted through the Silverlight configuration, as shown below.

image

We can use isolated storage in a number of ways. Let’s take a look at the sample for this post. Below is a screenshot of the very simple UI I created for this sample. It allows a user to enter a text, representing his preferred background color for the application. We’ll store this value using the IsolatedStorage. Secondly, using another feature called IsolatedStorageSettings, I’m allowing the user to store a second value, which is used for the color of a StackPanel ( the blue bar in the screenshot).

image

First, let’s look at the code for the background color, using the regular IsolatedStorage. Below you can see the code. Working with IsolatedStorage is done using the IsolatedStorageFile class. It defines among others, the GetUserStoreForApplication static method, which returns the data store, for the specific user and the current application. From there on, working with IsolatedStorage is similar to working with the regular file system. Isolated storage is not to be seen as one file, it’s an entire file system, that can contain directories and files. In this code, we are creating using System.IO code a file called color.txt and writing some data to this file.

private void ColorButton_Click(object sender, RoutedEventArgs e)
{
  try
  {
    IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
 
    using (IsolatedStorageFileStream fs = isoStore.CreateFile("color.txt"))
    {
      StreamWriter writer = new StreamWriter(fs);
      writer.Write(ColorTextBox.Text);
      writer.Close();
    }
    ChangeColor(ColorTextBox.Text);
  }
  catch (Exception)
  {
    //handle error here, not for demo
  }
}

On load of the application, we need to check if this file already exists and if yes, read the file and set the background to that specific color. This is shown in the code below.

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
  try
  {
    IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
 
    if (isoStore.FileExists("color.txt"))
    {
      using (IsolatedStorageFileStream fs = isoStore.OpenFile("color.txt", FileMode.Open))
      {
        StreamReader reader = new StreamReader(fs);
        ChangeColor(reader.ReadLine());
        reader.Close();
      }
    }
  }
  catch (Exception)
  {
    //handle error here, not for demo
  }
}

In ASP.NET, we have the Application and Session objects, which provide an easy and quick way to store information between requests. Through a feature of the IsolatedStorage, we can have something quite similar. The IsolatedStorageSettings allow us a key/value lookup to store data. We don’t have to write code to actually store the files, it does that for us. Take a look at the following code. We allow the user to store a second string for the background of the StackPanel.

private void AppColorButton_Click(object sender, RoutedEventArgs e)
{
  IsolatedStorageSettings.ApplicationSettings["AppColor"] = AppColorTextBox.Text;
  ChangeStackPanelColor(AppColorTextBox.Text);
}

Using this approach, we say for the AppColor value, store the contents of the TextBox as value. Behind the scenes, this is persisted, so it can be retrieved after the application has been shutdown (it is thus not stored in application memory). Retrieving the value can be done as follows:

if (IsolatedStorageSettings.ApplicationSettings.Contains("AppColor"))
{
  string appColor = IsolatedStorageSettings.ApplicationSettings["AppColor"].ToString();
  ChangeStackPanelColor(appColor);
}

The complete sample can be downloaded here: SLIsolatedStorage.zip (30.84 KB)
  Posted on: Sunday, December 20, 2009 12:26:40 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 19, 2009    

The day before yesterday, we looked at an sample with Twitter: we retrieved the tweets from the public timeline in an OOB trusted application. The public timeline feed on Twitter requires no credentials to be passed along. Some other feeds however do, such as the user timeline (containing your own tweets) and the friends timeline (containing the tweets of your friends).

Up until Silverlight 4, passing credentials to a service was not supported. Silverlight 3 added support for the ClientHttp stack, however, it was not possible to modify the authorization header, resulting in it being impossible to pass credentials. Silverlight 4 adds this support however. In combination with the support for cross-domain access for services for Silverlight if they are executed with elevated permissions, we can easily build a more complete Twitter client in Silverlight. We already did some work on this application, we will now extend it to make it possible to execute requests to services that require authorization.

Below is a screenshot of the modified application, running OOB as a trusted application.

image

We will not be looking at the code for the public timeline, that was already covered two days ago. Instead, let’s focus on the code we need to write to make the authorized request possible. Of course, we need the user’s credentials, therefore, I added a username/password field.

When clicking on the Submit button, two request are being executed:

Here’s the code for the first one. Note a few things. Passing credentials is only possible if using the ClientHttp stack. This is enabled by WebRequest.RegisterPrefix("http://", System.Net.Browser.WebRequestCreator.ClientHttp). This selects the ClientHttp stack instead of the browser http stack, which is used by default. To pass the credentials, we use the Credentials property and set it to an instance of NetworkCredentials. Here’s the code.

WebRequest.RegisterPrefix("http://", System.Net.Browser.WebRequestCreator.ClientHttp);
//try finding the user tweets and friends tweets
string userTimeLine = "http://twitter.com/statuses/user_timeline/" + 
  UserNameTextBox.Text + ".xml";
WebClient client = new WebClient();
client.Credentials = new NetworkCredential(UserNameTextBox.Text, 
  PasswordTextBox.Password);
client.UseDefaultCredentials = false;
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler
  (user_DownloadStringCompleted);
 
client.DownloadStringAsync(new Uri(userTimeLine, UriKind.Absolute));

A very important line is setting the UseDefaultCredentials to false. If we set it to true, Silverlight will pass the credentials of the logged-on user on the machine (NTLM). If this is the wanted behavior however, simply setting this property to true will of course enable this.

The complete code for this application can be downloaded here:

SLTwitterCredentials.zip (82.89 KB)
  Posted on: Saturday, December 19, 2009 9:24:22 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 18, 2009    

After looking at Twitter yesterday, we have arrived at another data binding-related feature new in Silverlight 4, namely the support for the IDataErrorInfo interface.

The fact that Silverlight supports this interface now, means we can fully use it to help with the display of validation errors in a data binding scenario. The interface itself is quite simple, as shown below:

public interface IDataErrorInfo
{
    string Error { get; }
 
    string this[string columnName] { get; }
}

When we are binding an object of a class that implements the IDataErrorInfo, Silverlight will automatically check each field for validation errors using the indexer. In here, we can write validation code that will check if the specified value is valid and if not, return the error message for that field. Silverlight will then automatically display the error for the field.

I have created a small sample that does exactly that. Being it almost Christmas, I have created a sample where the user can enter his christmas music collection, as shown below.

image

The type we are binding to is called ChristmasSong. This class implements both the INotifyPropertyChanged and the IDataErrorInfo interfaces. Both have been implemented in the code below. In the indexer, we are checking per column if the entered value is valid. If not, we are returning a message containing the validation error. Note that when we are entering “Last Christmas” by “Wham”, the application will not accept it! (Sorry to all Wham fans ;-) )

public class ChristmasSong : IDataErrorInfo, INotifyPropertyChanged
{
    private string title;
    private string performedBy;
    private TimeSpan duration;
    private DateTime published;
 
    private string error;
 
    public event PropertyChangedEventHandler PropertyChanged;
 
    protected void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
 
    public string Title
    {
        get
        {
            return title;
        }
        set
        {
            title = value;
            NotifyPropertyChanged("Title");
        }
    }
 
    public string PerformedBy
    {
        get
        {
            return performedBy;
        }
        set
        {
            performedBy = value;
            NotifyPropertyChanged("PerformedBy");
        }
    }
 
    public TimeSpan Duration
    {
        get
        {
            return duration;
        }
        set
        {
            duration = value;
            NotifyPropertyChanged("Duration");
        }
    }
 
    public DateTime Published
    {
        get
        {
            return published;
        }
        set
        {
            published = value;
            NotifyPropertyChanged("Published");
        }
    }
 
    public string Error
    {
        get { return error; }
    }
 
    public string this[string columnName]
    {
        get 
        {
            string error = string.Empty;
            switch (columnName)
            {
                case "Title":
                    if(string.IsNullOrEmpty(title))
                        error = "Title can not be blank";
                    break;
                case "PerformedBy":
                    if(string.IsNullOrEmpty(performedBy))
                        error = "The artist should be filled in";
                    else if(performedBy.Equals("Wham") && title.Equals("Last Christmas"))
                        error = "You should NOT be entering that song to your collection!";
                    break;
                case "Duration":
                    if(duration.TotalSeconds > 600)
                    error = "A song can not be longer than 10 minutes";
                    break;
                case "Published":
                    if (Published > new DateTime(2010, 1, 1))
                        error = "You found a song from the future?";
                    else if (published < new DateTime(1900, 1, 1))
                        error = "That's a bit too old, isn't it?";
                    break;
            }
            return error;
        }
    }
}

We can now bind our UI to an instance of this type. Below is the XAML code for the Grid containing the fields. Note especially the data binding expression, where I’m stating the fields should be reporting the error back. For spacing reasons, I only pasted the Title field, the others are similar.

<TextBlock x:Name="TitleTextBlock" Text="Title" Grid.Row="1"  
  Foreground="Red" HorizontalAlignment="Left" Margin="2" 
  VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="TitleTextBox" Grid.Row="1" Grid.Column="1" Width="200" 
  VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2" 
  Text="{Binding Path=Title, Mode=TwoWay, ValidatesOnDataErrors=True, 
    NotifyOnValidationError=True}" />

When we are entering data now, the validation will kick in whenever a validation error is encountered.

We can take it one step further though, using the BindingValidationError event, defined on FrameworkElement. This event will trigger whenever a binding error is reported by the binding source, being here the instance of the ChristmasSong class. In this event, we can through the e.Action property check if an error was added or resolved. In this particular code, I have specified that the Submit button will only become enabled when there are no more errors.

private void ChristmasSongGrid_BindingValidationError(object sender, 
  ValidationErrorEventArgs e)
{
  switch (e.Action)
  {
    case ValidationErrorEventAction.Added:
         errorsOnPage++;
         break;
    case ValidationErrorEventAction.Removed:
         errorsOnPage--;
         break;
  }
  if (errorsOnPage == 0)
    SubmitButton.IsEnabled = true;
  else
    SubmitButton.IsEnabled = false;
}

All this can be seen in action, when we are entering “Last Christmas” by “Wham”!

image

The sample code can be downloaded here: SLDataErrorInfo.zip (308.96 KB)

  Posted on: Friday, December 18, 2009 12:06:56 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 17, 2009    

In today’s article, we’re looking at cross-domain access to a service in Silverlight 4’s trusted applications.

As you may know, when accessing any service located in a domain different from the one in which the Silverlight application itself is hosted, Silverlight will check for a cross domain file being in place. Cross-domain policies prevent Silverlight applications to connect with services that are not in the same domain. However, a service can opt-in to be connected to if at the root of the domain, a cross-domain policy file has been deployed. Silverlight will check for its existence (the file should be named clientaccesspolicy.xml or crossdomain.xml, which is the cross-domain file of Flash) and if found, Silverlight will connect in a cross-domain manner.

Services such as Twitter and Facebook do not deploy this file anymore. Flickr does, meaning that we can connect to Flickr from a client-side Silverlight application. If we want to connect with Twitter from Silverlight, we have to create a service within the same domain as where the Silverlight application is hosted. This service can then communicate with Twitter and Silverlight can communicate with our service.

In Silverlight 4, the notion of trusted applications was added (we looked in this blog series already to some other concepts available when running a trusted application such as COM interop and local file access). If a Silverlight application is running as a trusted application, it can perform cross-domain calls, without there needing to be a cross domain policy file in place. That means that we can build a Twitter client as a trusted Silverlight application without having to build an extra service layer in between.

In the sample I have built for this post, I’m doing exactly that. Below is a screenshot. The UI of the application contains a templated ListBox. Note that the application is running OOB as a trusted application.

image

The code for this application is quite easy. It’s the same code we would write to access a “local” service, meaning a service in the same domain. Below is the code to access Twitter, an asynchronous web service call using the WebClient class.

public void GetPublicTimeLine()
{
    string publicTimeLine = "http://twitter.com/statuses/public_timeline.xml";
    WebClient client = new WebClient();
    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler
      (client_DownloadStringCompleted);
    client.DownloadStringAsync(new Uri(publicTimeLine, UriKind.Absolute));
}
 
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    XDocument document = XDocument.Parse(e.Result);
    twitterData = (from status in document.Descendants("status")
                   select new Tweet
                   {
                     Message = status.Element("text").Value.Trim(),
                     User = status.Element("user").Element("name").Value.Trim()
                     }).ToList();
 
    PublicTimeLineListBox.ItemsSource = twitterData;
}

This code is executed when a user clicks on the “Load Twitter Messages” button at the top. We do perform a check to see if the application is running OOB and is running with elevated permissions.

private void LoadTwitterButton_Click(object sender, RoutedEventArgs e)
{
    if (Application.Current.IsRunningOutOfBrowser && 
            Application.Current.HasElevatedPermissions)
    {
        //it's OK to access Twitter services cross domain now
        GetPublicTimeLine();
    }
}

Tomorrow, we will look at extending this sample by allowing to send credentials to Twitter to access personalized streams of tweets.

The complete sample can be downloaded here.

SLTrustedTwitter.zip (269 KB)
  Posted on: Thursday, December 17, 2009 4:52:54 PM (Romance Standard Time, UTC+01:00)   |   Comments [3]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 16, 2009    

The DataGrid is probably the most popular control in many business applications. Added in Silverlight 2, this control allows for easy displaying and editing of data in a tabular format. While already a very decent control, the DataGrid in Silverlight 2 and 3 still had some things that were missing or not working like you’d hope them to. In today’s post, we’ll look at the newly added changes to the control.

The first and probably biggest change is the auto-sizing option for columns. In previous versions, we could basically specify a column width or specify nothing at all, leaving it to Silverlight. What we could not do, was saying to a specific column: Take all the remaining space, similar to what we can do with the Grid control through the use of *.

Basically, there are now 5 options we have to specify how a column should behave (copied from the MSDN docs):

Member name
Description
Auto
The unit of measure is based on the size of the cells and the column header.
Pixel The unit of measure is expressed in pixels.
SizeToCells The unit of measure is based on the size of the cells.
SizeToHeader The unit of measure is based on the size of the column header.
Star The unit of measure is a weighted proportion of the available space.

Let’s take a look at using these in an example. I created a random data generator (see sample code download), which generates Employee instances. These are stored in a generic list which is then set as the ItemsSource for a DataGrid. The result can be see below.

image

As you can see in the screenshot, the Address column is wider than the others. I actually specified it to be twice as wide as the FirstName and the LastName columns. The City column has a specific width set.

<data:DataGrid AutoGenerateColumns="False" x:Name="EmployeeDataGrid" 
    HeadersVisibility="All" Grid.Row="1">
    <data:DataGrid.Columns>
        <data:DataGridTextColumn Header="FirstName" Binding="{Binding FirstName}" Width="*"/>
        <data:DataGridTextColumn Header="LastName" Binding="{Binding LastName}" Width="*"/>
        <data:DataGridTextColumn Header="Address" Binding="{Binding Address}" Width="2*"/>
        <data:DataGridTextColumn Header="City" Binding="{Binding City}" Width="100" />
    </data:DataGrid.Columns>
</data:DataGrid>

We can also use the other options. By clicking on the Change button at the top, we switch the DataGrid to use another sizing option.

private void ChangeColumnsButton_Click(object sender, RoutedEventArgs e)
{
    EmployeeDataGrid.Columns[0].Width = new DataGridLength(1, 
        DataGridLengthUnitType.SizeToCells);
    EmployeeDataGrid.Columns[1].Width = new DataGridLength(1, 
        DataGridLengthUnitType.SizeToCells);
    EmployeeDataGrid.Columns[2].Width = new DataGridLength(1, 
        DataGridLengthUnitType.SizeToCells);
    EmployeeDataGrid.Columns[3].Width = new DataGridLength(1, 
        DataGridLengthUnitType.Star);
}

This results in the following:

image

The first three columns are sizing to their contents. The City column takes all the remaining space.

The second new feature concerning the DataGrid, is the ability to copy data from the DataGrid to Excel. This feature is really handy in business applications. Very often, we need to be able to export data from an application towards Excel. This can make this very easy to do.

When we start a copy by selecting one or more rows, we are shown a prompt, asking us if we want to allow access to the clipboard. If confirmed, the data is copied as textual information and can be pasted in Excel.

There’s an event fired per row that is copied to the clipboard, namely the CopyingRowClipboardContent event. In this event, we can see what data is being copied and if needed apply transformations on it.

private void EmployeeDataGrid_CopyingRowClipboardContent(object sender, 
    DataGridRowClipboardEventArgs e)
{
    // do something
}
The complete sample can be downloaded here. SLNewDataGrid.zip (1.04 MB)
  Posted on: Wednesday, December 16, 2009 10:10:05 PM (Romance Standard Time, UTC+01:00)   |   Comments [2]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 15, 2009    

In today’s article, we’ll be looking at another new feature that was added with Silverlight 4, namely the ability to react to right-clicks in a Silverlight application. This means that we can override the default behavior of Silverlight where it’s showing the context menu allowing us to go to the configuration screen.

Because Silverlight now supports right-clicking, we can create a context menu that appears on the right-click event. We can code this context menu as we want. Right-clicking is supported on any UIElement: on the UIElement class, there are two new events added, namely the MouseRightButtonDown and the MouseRightButtonUp. Both of these new events use MouseButtonEventArgs as their event arguments, which are also used for the normal left click events.

As said, by default, the Silverlight context menu is shown when a user right-clicks on a Silverlight application. To block this, in the MouseRightButtonDown, we have to set the e.Handled to true. This way, the default context menu is not shown and we can go ahead and create our own context menu. This will appear on the MouseLeftButtonUp event.

Let’s take a look at a simple application. In this application, we have attached a custom context menu on an Image control. Using this context menu, I can choose to delete the image I clicked on.

image

The image itself has both the MouseRightButtonDown and the MouseRightButtonUp events attached to it using XAML code:

<Image Height="195" x:Name="imgTree" Stretch="Fill" Width="249" 
   MouseRightButtonDown="imgTree_MouseRightButtonDown" 
   MouseRightButtonUp="imgTree_MouseRightButtonUp" 
   Source="tree.png" Canvas.Left="181" Canvas.Top="79">
</Image>

To prevent the default context menu from appearing, we can set the e.Handled to true in the mouse down event:

private void imgTree_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
    e.Handled = true;
}

In the mouse up event, we can then specify what context menu we want to have appear:

private void imgTree_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
    Image image = sender as Image;
    if (image != null)
    {
        ContextMenu contextMenu = new ContextMenu(PrintCanvas, image);
        contextMenu.Show(e.GetPosition(LayoutRoot));
    }
}

The ContextMenu used here is a custom control.

The complete source code can be downloaded here: SLRightClick.zip (473.2 KB)

  Posted on: Tuesday, December 15, 2009 11:21:21 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 14, 2009    

Only 10 days ‘till Christmas and thus only 10 more posts after this one to finish my series. In today’s post, we’ll be taking a look at the Local Connection API, a feature introduced with Silverlight 3.

Most of the time, we build full-screen Silverlight applications, meaning that the only function that the HTML still fulfills, is hosting a DIV that will contain the HTML OBJECT tag in which Silverlight will be hosted. However, sometimes Silverlight could be used as an “island” on an HTML page. For example, we could have an HTML page (perhaps rendered by ASP.NET) in which a table of data is shown. The end-user may want a richer experience with this data grid such as reordering rows, efficient paging and so on. We could decide to just convert that specific part to functionality to Silverlight, resulting in a Silverlight island.

To go even further, in some scenarios, it may be needed that two or more of these Silverlight islands live on a single page. Silverlight 2 introduced the HTML Bridge to allow these two Silverlight plug-ins to talk to one another: using Javascript as an intermediate, we could send messages from control 1 to control 2 and vice-versa. While possible, it’s not the easiest way of developing an application.

Silverlight 3 introduced something easier for this particular problem, namely the local connection API. It basically allows two or more Silverlight instances to communicate with each other. These two instances can live on the same page, but can even live on two different browser tabs or even two different browser windows. The API uses a concept of a named pipe: a named sender sends a message into a pipe and a receiver can intercept this message. The message needs to be a string.

The messaging system introduced is based on two types, LocalMessageSender and LocalMessageReceiver, both types that live in the System.Windows.Messaging namespace.

Let’s take a look at an example. The application I built for this post contains two Silverlight controls. The first control contains a few buttons. When clicking on a button, I want to change the background of control n° 2. (Note that these are actually 2 different Silverlight applications hosted on one single page).

image

The first thing we need to do is creating an instance of the LocalMessageSender class. As parameter, we pass in the name that will be used as the identification (ColorSender), like so:

private LocalMessageSender localMessageSender;
private LocalMessageReceiver localMessageReceiver;
 
public MainPage()
{
    InitializeComponent();
    localMessageSender = new LocalMessageSender("ColorSender");
 
}

When we click on a button, we’ll send a message using this instance. In this case, we pass in the name of the color we want:

private void RedButton_Click(object sender, RoutedEventArgs e)
{
  localMessageSender.SendAsync("Red");
}
 
private void GreenButton_Click(object sender, RoutedEventArgs e)
{
  localMessageSender.SendAsync("Green");
}
 
private void BlueButton_Click(object sender, RoutedEventArgs e)
{
  localMessageSender.SendAsync("Blue");
}

In the second application, we create a LocalMessageReceiver, passing in the same string, ColorSender, as the name of the sender it should listen to. We then specify the handler for the MessageReceived event, which will trigger when a string is received. The receiver starts listening for values by calling its Listen() method:

private LocalMessageReceiver localMessageReceiver;
 
public MainPage()
{
  InitializeComponent();
  localMessageReceiver = new LocalMessageReceiver("ColorSender");
  localMessageReceiver.MessageReceived += 
  new EventHandler<MessageReceivedEventArgs>(localMessageReceiver_MessageReceived);
  localMessageReceiver.Listen();
}

Based on the value of the received message, we change the color:

void localMessageReceiver_MessageReceived(object sender, MessageReceivedEventArgs e)
{
  switch (e.Message)
  {
    case "Red": LayoutRoot.Background = new SolidColorBrush(Colors.Red);
                ColorTextBlock.Text = "RED";
                break;
    case "Green": LayoutRoot.Background = new SolidColorBrush(Colors.Green);
                  ColorTextBlock.Text = "GREEN";
                  break;
    case "Blue": LayoutRoot.Background = new SolidColorBrush(Colors.Blue);
                 ColorTextBlock.Text = "BLUE";
                 break;
    default: LayoutRoot.Background = new SolidColorBrush(Colors.White);
             ColorTextBlock.Text = "WHITE";
             break;
  }
}

The code can be downloaded here: SLLocalConnection.zip (97.1 KB)

  Posted on: Monday, December 14, 2009 9:31:33 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     Silverlight | Silverlight Advent Calendar | sl4     December 14, 2009    

I hope you are all enjoying my post series Silverlight Advent Calendar. I still have a list of upcoming articles, but I was wondering, are there any specific things you would like to see appear?

I have one request already for an article on the local connection API, that will come in the coming days.

Let me know your ideas!

  Posted on: Monday, December 14, 2009 8:57:06 AM (Romance Standard Time, UTC+01:00)   |   Comments [4]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 13, 2009    

In today’s post, we will be working with services. As some of you know, I’m currently finishing my first book titled Silverlight 4 Data Access Cookbook. If all goes well, it will be available in early access preview somewhere in the coming week. Therefore, I decided I needed to write a post that’s in the same area as my book. More specifically, I’ll be creating a application that works together with the services API exposed by Bing.com, Microsoft’s new and successful search engine.

Bing has a very rich API that we can use to incorporate search functionalities in our applications, including Silverlight applications. It allows us to use WCF (SOAP) and REST communication, because it exposes endpoints for both these technologies. In this particular example, I’m using the SOAP interface for communication using a WCF service. To get a complete overview of the functionalities, you can download the PDF describing the entire API at http://www.bing.com/developers/s/API%20Basics.pdf . It also contains some sample code.

The very first thing we should before we can actually start building applications with Bing, is obtaining an API key. This key is required so Bing can check that your request is valid (this key will be part of every request you’ll send to Bing). Obtaining a key is free and can be done at http://www.bing.com/developers/createapp.aspx .

The provided sample is a Silverlight 4/VS2010 solution, all the code included however also works with Visual Studio 2008/Silverlight 3.

First, we need to generate a proxy using Visual Studio 2010. For this, we need the address of the WSDL (Web Service Description Language) file. In the documentation, we can find that this address is: http://api.search.live.net/search.wsdl?AppID=12345 where 12345 needs to be replaced with your obtained API key. In Visual Studio, we add the service reference using the dialog and I have set the namespace to BingSearchService.

image

Visual Studio will at this point create the proxy for the service. A proxy contains a client-side copy of the types exposed by the service and its methods. The contents of the methods is replaced with a call to the real service method. In the client-side code, we can now work with these types and methods.

In the screenshot a bit further, you can see the interface of the application. It contains a TextBox and a Button to search and a templated ListBox to display the results. Let’s first create the code for the event handler of the click event. Bing accepts quite a lot of parameters for the search it needs to perform. These are encapsulated in an object of type SearchRequest. Since we are conducting a normal web search, we specify this in the Sources property of the SearchRequest instance. A search with Bing is a service request, so all communication needs to be done asynchronously. We can see this at the way we are calling the service using the SearchCompleted event and SearchAsync() method. Below is the code.

private void SearchButton_Click(object sender, RoutedEventArgs e)
{
  LiveSearchPortTypeClient soapClient = new LiveSearchPortTypeClient();
  SearchRequest request = new SearchRequest();
  request.AppId = "81691C6A195FBC3FB469594BAA30B50A99CF3D22";
  request.Sources = new SourceType[] { SourceType.Web };
 
  if (SearchTextBox.Text != string.Empty)
  {
    request.Query = SearchTextBox.Text;
    soapClient.SearchCompleted += 
      new EventHandler<SearchCompletedEventArgs>(soapClient_SearchCompleted);
    soapClient.SearchAsync(request);
  }
}

When the service completes asynchronously, meaning, when Bing’s results are ready and available, the *Completed event is called and executed. In this event handler, we have access to the results of the service call. The result can be found in the e.Result parameter and is always of the same type as returned by the service. In our specific case, the used type is a SearchResponse, again a type exposed by the Bing services. We can now loop through these results and using a simple LINQ query, create an IEnumberable<SearchResult> . SearchResult is a type created by us to allow us to data bind to the results. This type is very simple:

public class SearchResult
{
    public string SearchResultTitle { get; set; }
    public string SearchResultDescription { get; set; }
    public string SearchResultUri { get; set; }
}

The code for the event handler is shown next:

void soapClient_SearchCompleted(object sender, SearchCompletedEventArgs e)
{
    SearchResponse response = e.Result;
    if (response.Web.Results.Count() > 0)
    {
        var results = from result in response.Web.Results
                      select new SearchResult
                      {
                          SearchResultTitle = result.Title,
                          SearchResultUri = result.Url,
                          SearchResultDescription = result.Description
                      };
        ResultListBox.ItemsSource = results.ToList();
    }
}

The ListBox is as said templated; the ItemsTemplate has been replaced with a custom data template, as shown below:

<ListBox x:Name="ResultListBox" Grid.Row="1" Margin="3" Background="Black">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <TextBlock Text="{Binding SearchResultTitle}" FontWeight="Bold" 
          FontSize="15" TextDecorations="Underline" Foreground="White"></TextBlock>
        <TextBlock Text="{Binding SearchResultDescription}" Grid.Row="1" 
          TextWrapping="Wrap" Width="400" HorizontalAlignment="Left" 
          Foreground="White"></TextBlock>
        <TextBlock Text="{Binding SearchResultUri}" Grid.Row="2" Foreground="#568e71">
        </TextBlock>
      </Grid>
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

When we now execute a search using our application, we see the following:

image

The complete sample can be downloaded here:

SLBing.zip (790.49 KB)
  Posted on: Sunday, December 13, 2009 12:48:53 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 11, 2009    

I made it through the first half of my Silverlight Advent Calendar! You’re currently reading the 12th installment of my article series. In this article, we are looking at the RichTextArea control, which was added to the platform with Silverlight 4.

Up until Silverlight 4, we had no real way to perform rich text editing. Some (open source) implementations have been built of which the best one is in my opinion VectorLight.com’s RichTextBox/RichTextBlock (check it out at www.vectorlight.com, they have quite some nice controls). Silverlight 4 introduces the RichTextArea control. Its name already implies what it is capable of: allowing us to do rich text editing in our Silverlight applications. Things like making text bold, italic or underlined are of course supported by this control. On top of that, more advanced options are available, such as adding hyperlinks in text, adding images and adding XAML content. It can also out-of-the-box work with the clipboard and offers BiDi support. The latter is important for some languages such as Hebrew, since these are right-to-left languages.

Behind the visual of the control, text is being added as XAML, so in fact, the control is rendering the result of that XAML. This XAML is XAML like we know it for displaying rich text using TextBlock controls, containing Paragraphs, Runs and LineBreaks. At the time of writing, there is no real Text property on the control to get the entered text without the markup. To get the contents, we can use the Blocks collection to loop through the content. This is a bit of a setback and I can only hope it will in some way become possible to get the text from the control as well (without the markup).

Using this new control, we can thus perform most of the actions we’ll want to do with text. The control does not have buttons by default, so we need to add them ourselves. Below is an implementation of the control in combination with a ribbon (found in the official Silverlight 4 whitepaper/documentation).

image

Let’s take a look a simple implementation now. My implementation will make it possible to add text (quite logically), make it bold, underlined or italic. We’ll also add the possibility to change the color of the selected text and print it using the new printing functions in Silverlight 4.

image

Below is the XAML for the RichTextArea (nothing special as you can see):

<RichTextArea x:Name="MainRichTextArea" Height="300"></RichTextArea>

To implement the different functions, we need to add some code in the event handlers of the button click events. For example, if we want to make the selected text bold, we start by checking if text is selected. If there is, we check if the selected text is already bold or not. We set it to bold if it isn’t and vice-versa of course. The code for this is shown below.

private void BoldButton_Click(object sender, RoutedEventArgs e)
{
  if (MainRichTextArea.Selection.Text.Length > 0)
  {
    if (MainRichTextArea.Selection.GetPropertyValue(Run.FontWeightProperty) 
        is FontWeight &&
        ((FontWeight)MainRichTextArea.Selection.GetPropertyValue
        (Run.FontWeightProperty)) == FontWeights.Normal)
        {
          MainRichTextArea.Selection.SetPropertyValue(Run.FontWeightProperty, 
            FontWeights.Bold);  
        }
    else
        MainRichTextArea.Selection.SetPropertyValue(Run.FontWeightProperty, 
          FontWeights.Normal);
        MainRichTextArea.Focus();
    }
}

The code is similar for the other actions, it can be found in the sample code download. When we want to print our added text, we have 2 options. The most simple one is pointing the PageVisual to the RichTextArea:

private void PrintButton_Click(object sender, RoutedEventArgs e)
{
  PrintDocument printDocument = new PrintDocument();
  printDocument.DocumentName = "My rich text";
 
  printDocument.PrintPage += (s, args) =>
  {
    args.PageVisual = MainRichTextArea;
  };
  printDocument.Print();
}

The second option exists out of looping through the Blocks collection of the RichTextArea, parsing each of the retrieved items and adding them to the Inlines collection of a TextBlock control.

The sample code can be downloaded here: SLRichTextArea.zip (84.68 KB)

  Posted on: Saturday, December 12, 2009 12:49:28 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 11, 2009    

One day away from finishing the first 12 (half of the total of 24 ;-) )of my Silverlight articles. In this post, we are looking at local file access in Silverlight 4. This new feature is another one that is only enabled with OOB apps with elevated permissions.

In Silverlight 2 and 3, we already had some basic file access. We could perform an OpenFileDialog starting with Silverlight 2. It gave us a read-only stream to the selected file, meaning that the only thing we could do with the file, was reading it and using its contents in the application. Silverlight 3 added the SaveFileDialog, which, surprisingly, allows us to save files to the local disk.

Silverlight 4 ads more or less real local data access. By more or less, I mean that Silverlight applications can only access some folders. More particularly, we can access the My Documents, My Pictures, My Videos and My Music folders (on Mac, an equivalent exists). Within this directory, we can read, create and delete files. One important side-note though: the application needs to be a trusted application, meaning that it needs to run with elevated permissions.

Silverlight has a specific enumeration that we can use to get the physical location of the files: Environment.SpecialFolder. In it, we can find MyPictures etc. Note that it contains more than what we can access at this point, for example ProgramFiles. Even if we try to do something with this, we can’t since Silverlight won’t allow access to this directory.

Let’s take a look at a basic application as shown below.

image

Let’s first take a look at the left listbox, which is filled with the files of my My Pictures folder. Reading out the files, as well as other operations on the files, are done using the traditional classes contained in the System.IO namespace, such as Directory, File, Path etc. To read out the contents, we use the following code:

if (canWork)
{
  var files = Directory.EnumerateFiles(Environment.GetFolderPath
   (Environment.SpecialFolder.MyPictures));
  foreach (var file in files)
    {
      string fileName = System.IO.Path.GetFileName(file);
      imageNames.Add(fileName);
    }
    ImageListBox.ItemsSource = imageNames;
}

Note the canWork bool value. Since the application can only work if running OOB and with elevated permissions, we perform a check initially to see if the operations are permitted. The value is set through the following code:

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
  //check to see if application is running OOB and with elevated permissions
  if (App.Current.IsRunningOutOfBrowser && App.Current.HasElevatedPermissions)
    canWork = true;
  else
    MessageBox.Show("The application needs to run out-of-browser with 
      elevated permissions");
}

The second listbox is filled with all *.txt files, located in my My Documents folder: I’m simply applying a filter.

private void FetchTextFiles()
{
    var files = Directory.EnumerateFiles(Environment.GetFolderPath
     (Environment.SpecialFolder.MyDocuments))
     .Where(filename => filename.EndsWith("txt"));
    
    TextFilesListBox.ItemsSource = files;
}

As said, we can do more than just reading out the contents of a directory. We can for example delete a file. When we select a file in the second listbox, we can delete it using the following code:

private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
  if (canWork)
  {
    if (TextFilesListBox.SelectedItem != null)
    {
      string path = TextFilesListBox.SelectedItem.ToString();
      File.Delete(path);
      FetchTextFiles();
    }
  }
}

As you can see, working with the files is no different than working with files in plain .NET.

The code can be downloaded here: SLLocalFileAccess.zip (68.26 KB)

  Posted on: Friday, December 11, 2009 10:34:42 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 10, 2009    

Today, we are looking again at another new feature in Silverlight 4 which is the support for webcams and microphones.

Silverlight 4 gets support for microphones and webcams. It has access to the raw streams for both. The added support opens a lot of opportunities for new types of applications. For example, it becomes possible to write an application that reads barcodes of products you hold in front of the webcam, scans them and searches for product information.

The classes that expose this functionality live in the System.Windows.Media namespace. We’ll be using those to create a simple application that connects with the webcam and takes snapshots. Below is the interface of the application (a colleague of mine was just eating a banana :) )

image

The XAML for the application is shown below. The ComboBox displays the available webcams (only one on my machine), we are binding to the FriendlyName property. The ListBox is templated: both the ItemsTemplate and the ItemsPanel are overriden, to have the control display a horizontal list of images.

<Grid x:Name="LayoutRoot" Background="White">
  <Grid.RowDefinitions>
    <RowDefinition Height="330"></RowDefinition>
      <RowDefinition Height="50"></RowDefinition>
        <RowDefinition Height="140"></RowDefinition>
  </Grid.RowDefinitions>
  <Border BorderBrush="Black" BorderThickness="3" HorizontalAlignment="Center" 
    VerticalAlignment="Center">
    <Rectangle x:Name="WebcamRectangle" Fill="LightGray" Height="300" 
      Width="400"></Rectangle>
  </Border>
  <StackPanel Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Center" 
    HorizontalAlignment="Center">
    <ComboBox x:Name="WebcamComboBox" Width="200" Margin="3" 
      SelectionChanged="WebcamComboBox_SelectionChanged">
      <ComboBox.ItemTemplate>
        <DataTemplate>
          <TextBlock Text="{Binding FriendlyName}"></TextBlock>
        </DataTemplate>
      </ComboBox.ItemTemplate>
    </ComboBox>
    <Button x:Name="StartWebcamButton" Click="StartWebcamButton_Click" 
      Content="Start webcam" HorizontalAlignment="Center" Margin="3"></Button>
    <Button x:Name="TakePictureButton" Click="TakePictureButton_Click" 
      Content="Take picture" HorizontalAlignment="Center" Margin="3"></Button>
  </StackPanel>
  <ListBox x:Name="PicListBox"  Width="500" Height="120" 
    ScrollViewer.HorizontalScrollBarVisibility="Visible"  Grid.Row="2">
    <ListBox.ItemTemplate>
      <DataTemplate>
        <Image Margin="5" Source="{Binding}" Stretch="UniformToFill" 
          Height="80" VerticalAlignment="Center"/>
      </DataTemplate>
    </ListBox.ItemTemplate>
    <ListBox.ItemsPanel>
      <ItemsPanelTemplate>
        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" 
          HorizontalAlignment="Left"/>
      </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
  </ListBox>
</Grid>

To fill the ComboBox with the available webcams, we can use the CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices(). This returns a Collection of VideoCaptureDevice instances. The VideoCaptureDevice class exposes the FriendlyName property we used in the data binding expression.

//fills the dropdown with all available webcams
WebcamComboBox.ItemsSource = 
  CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices();

We can instruct Silverlight to use the default capturing device, if nothing is selected by the user in the ComboBox:

//use the default
VideoCaptureDevice selectedVideoCaptureDevice = 
CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

A little side note: we can change the default device in the Silverlight Configuration window as shown below.

image

Starting the webcam needs to be a user-initiated action. It’s impossible to start the webcam on load of the application for example. Therefore, we put this code in the event handler of the click on the Button. Whenever the webcam is started, a prompt is shown, asking the user if he wants to allow the application to access the device. This prompt can not be changed by the developer.

image

The following lines of code, located in the click event handler, check if the user has already granted permission in this particular session to access the webcam. If not, the prompt is shown following the RequestDeviceAccess() method call.

if (CaptureDeviceConfiguration.AllowedDeviceAccess 
    || CaptureDeviceConfiguration.RequestDeviceAccess())
{
...
}

To access the video capture of the webcam, we use the CaptureSource class.

VideoCaptureDevice videoCaptureDevice = selectedVideoCaptureDevice;
CaptureSource captureSource = new CaptureSource();
captureSource.VideoCaptureDevice = videoCaptureDevice;

This CaptureSource can then be used in combination with a VideoBrush to paint the video on any shape. Here, we used a Rectangle. To start the capturing of the device associated with the capture device (note that more than one device can be associated with one CaptureSource), we call its Start() method.

VideoBrush videoBrush = new VideoBrush();
videoBrush.SetSource(captureSource);
WebcamRectangle.Fill = videoBrush;
captureSource.Start();

If we want to capture a snapshot, we can use the AsyncCaptureImage method. It provides a WriteableBitmap to the Action(T) which is passed in as parameter. We add the image to the collection. Because of the applied binding, it is displayed automatically.

private void TakePictureButton_Click(object sender, RoutedEventArgs e)
{
    captureSource.AsyncCaptureImage((snapshot) =>
    {
        snapshots.Add(snapshot);
    });
}

The complete code for today’s article can be found here: SLWebcam.zip (60.67 KB)

  Posted on: Thursday, December 10, 2009 11:33:15 AM (Romance Standard Time, UTC+01:00)   |   Comments [1]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 9, 2009    
Article number 9 is here, a bit later on the day since I was home late yesterday from the MVP dinner we had and left at 6am this morning to do the Silverlight Road Show. But here we are with the article of today, December 9th!

Today we are looking at a data binding feature that was introduced with Silverlight 3. The reason I’m dedicating an article to it, is that not that many people seem to know about this little gem, namely element-to-element binding or simply element binding. Regular data binding happens between a source object (for example a Person or a Customer) and a control such as a TextBlock. Element binding happens between 2 controls: a property of element A is bound to a property of element B.

A good example to understand element bindings is the following: a Slider control of which the Value property is bound to the Text property of a TextBlock.

image

To make the link between the 2 values, we create a binding as usual, but we specify the “source” as being another element, in this case the Slider control using the ElementName property on the binding.

<StackPanel x:Name="SliderStackPanel" Orientation="Horizontal" Grid.Row="0">
    <Slider x:Name="YearsToPensionSlider" Width="300" Minimum="0" Maximum="40" 
      SmallChange="1" LargeChange="1" VerticalAlignment="Center"></Slider>
    <TextBlock x:Name="ValueTextBlock" 
      Text="{Binding ElementName=YearsToPensionSlider, Path=Value}" 
      VerticalAlignment="Center"></TextBlock>
</StackPanel>

We can also make this binding a bi-directional binding. In the image above, in the second row, it’s possible to specify a value manually in the TextBox control. Due to the binding, the slider will also change its value if we specify the binding to be a two way binding, as so:

<StackPanel x:Name="SliderStackPanel2" Orientation="Horizontal" Grid.Row="1">
    <Slider x:Name="YearsToPensionSlider2" Width="300" Minimum="0" Maximum="40" 
      SmallChange="1" LargeChange="1" VerticalAlignment="Center"></Slider>
    <TextBox x:Name="ValueTextBox" 
      Text="{Binding ElementName=YearsToPensionSlider2, Path=Value, Mode=TwoWay}" 
      VerticalAlignment="Center" Width="100"></TextBox>
</StackPanel>

You can download the code for this sample here. This is a Visual Studio 2008 project and works both with Silverlight 3 and Silverlight 4.SLElementBinding.zip (59.38 KB)
  Posted on: Wednesday, December 09, 2009 11:35:28 PM (Romance Standard Time, UTC+01:00)   |   Comments [3]
         
Gill Cleeren     Silverlight     December 9, 2009    

Today, I have been all over Belgium for the Silverlight Roadshow. As promised, you can find the entire slide deck here.

It includes the general Silverlight slides as well as the Silverlight 3 and 4 feature overview slides.

  Posted on: Wednesday, December 09, 2009 9:25:32 PM (Romance Standard Time, UTC+01:00)   |   Comments [1]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 7, 2009    

Today, I picked another new feature of Silverlight 4, namely the programmatic access to and from the clipboard in Silverlight 4.

Silverlight 4 has the ability to copy text to the clipboard, check if there is text available on the clipboard and paste the text from the clipboard back to the Silverlight application. To support this, it has 3 static methods available on the newly added ClipBoard class:

  • Clipboard.SetText()
  • Clipboard.ContainsText()
  • Clipboard.GetText()

Let’s look at using these in a sample. Below we see the interface of the basic text editing application, containing 2 RichTextArea controls.

image

When clicking on the left button, we check if there’s some text selected in the left RichTextArea control. As said, this is done through the use of the static SetText() method on the ClipBoard class. Note that any interaction with the Clipboard class can only happen after a user-initiated action, such as clicking a Button.

private void CopyButton_Click(object sender, RoutedEventArgs e)
{
    if (CopyTextArea.Selection.Text != string.Empty)
    {
        WarningTextBlock.Text = string.Empty;
        Clipboard.SetText(CopyTextArea.Selection.Text);
    }
    else
    {
        WarningTextBlock.Text = "Select some text first";
    }
}

This call is supported both in-browser and out-of-browser. There’s a difference though. When accessing the clipboard from an in-browser application, a warning will be shown to the user, asking if the action to the clipboard is trusted.

image

If we however make our application a trusted application by requiring elevated permissions when running out-of-browser, it will no longer display this prompt (we looked at elevating permissions yesterday).

When we want to paste in the text using the paste button, we can use the 2 other before mentioned methods, like so:

private void PasteButton_Click(object sender, RoutedEventArgs e)
{
    if (Clipboard.ContainsText())
    {
        PasteTexArea.Selection.Text = Clipboard.GetText();
    }
    else
    {
        WarningTextBlock.Text = "No text exists on the clipboard";
    }
}

In the current beta, we can only copy text to and from the clipboard. Objects such as images are not supported at this point!

The complete code for this sample can be found here: SilverlightClipboard.zip (61.65 KB)

  Posted on: Tuesday, December 08, 2009 12:04:05 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 6, 2009    

December 7th already, this post marks the first week of my Silverlight Advent Calendar!

In today’s post, I’ll be looking at how to create a simple kiosk application. A kiosk application is typically something you see at a booth or a registration desk, filling the entire screen and only allowing the user to perform a specific action. In this specific example, I’m looking at how to create a user registration application which could typically be used for a kiosk.

As said, the most specific requirement for this type of applications, is being full screen. Silverlight 2 and 3 already supported full screen applications: making an application full screen could easily be done using the following line of code:

App.Current.Host.Content.IsFullScreen = true;

This code will only execute following a user-initiated action, such as a click on a Button. It’s thus not possible to load the application full screen by putting this line in some loaded event of the control.

Seems all quite well, doesn’t it? Indeed,  but there was one disappointment in all this: when in full screen, the user could not enter text, the text input was limited to some keys such as the arrow keys. Every character key was ignored. This behavior changed in Silverlight 4. In fact, I should say “can be changed” in Silverlight 4. By default, it will still not accept character keys in full screen, but when creating the application as OOB (Out Of Browser) application and giving it elevated permissions, it will accept them perfectly.

Elevated permissions

Before we look at the application itself, let’s first look at elevated permissions. In Silverlight 1, 2 and 3, code executed  always ran in the sandbox of the browser. There was no way to get out of this sandbox. Silverlight 4 adds a new type of application, namely a trusted Silverlight application, running with elevated permissions and allowing actions that were not possible in the previous versions. This means that we now have 3 possible modes in Silverlight 4: in-browser, out-of-browser (but still in the sandbox) and trusted (out-of-browser with elevated permissions).

Each application can be created to require elevated permissions to run. We can enable this by in the Project Properties window, clicking on the Out-of-Browser settings and then checking the following checkbox:

clip_image002

When the application is now installed, another dialog is displayed, warning the user that this application will have more permissions than “normal” installed apps. This dialog looks like the following screenshot.

image

We’ll come across more features in the following days which require elevated permissions such as COM interop and cross-domain service access.

Back to the kiosk

OK, now that we know that for our application, we’ll need elevated permissions, let’s look at some code and screenshots. The application is built as a navigation application. The application starts (by setting the root page) to an admin screen. In this screen, the admin can set the application to full screen. From then on, it is full screen and cannot be changed by the user.

image

When clicking on the button, the following code is executed:

private void FullScreenButton_Click(object sender, RoutedEventArgs e)
{
    App.Current.Host.Content.IsFullScreen = true;
}

The admin can then click the Start Wizard hyperlink, which will set the kiosk-registration application to its waiting screen.

image

In the following screen, the user can enter his/her details. In full-screen mode, this would NOT have been possible if:

  • we had used Silverlight 2 or Silverlight 3
  • we would not have set the application to require elevated permissions

Try for yourself disabling the elevated permissions requirement. If you run the application in full-screen then (in OOB mode), all text input in the text fields is ignored.

image

How to quit the application

When putting a trusted application in full-screen, by default hitting the ESCAPE key will not resize it back to its original position. Therefore, we can handle the keydown event in the MainWindow.xaml for example, as follows:

private void UserControl_KeyDown(object sender, KeyEventArgs e)
{
    if(e.Key == Key.Escape)
        App.Current.Host.Content.IsFullScreen = false;
}
The full code can be downloaded here: KioskApplication.zip (166.63 KB)
  Posted on: Monday, December 07, 2009 12:08:01 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 3, 2009    

Here we are with the 4th article already in my Silverlight Advent Calendar series!

When using data binding in Silverlight, we often have to include one or more converters. A converter is a class that implements the IValueConverter interface. This class defines 2 methods, Convert and ConvertBack. Convert is applied when the data in the data binding action flows from source object to target control. A common use for converters is formatting a date value that comes from the database into a specific format or adding a currency symbol to a double value. Below is a sample converter class:

public class CurrencyConverter : IValueConverter
    {
 
        #region IValueConverter Members
 
        public object Convert(object value, Type targetType, object parameter, 
            System.Globalization.CultureInfo culture)
        {
            double amount = double.Parse(value.ToString());
            if (amount < 0)
                return "- " + amount.ToString("c", culture);
            else
                return amount.ToString("c", culture);
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, 
            System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
 
        #endregion
    }

Silverlight 4’s data binding engine has been extended with a few options that in some cases can avoid forcing us to create a converter. More specifically, three new options have been added: TargetNullValue, StringFormat and FallbackValue.

For these samples, we’ll use a class called Customer:

public class Customer
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public DateTime BirthDate { get; set; }
    public string Email { get; set; }
}

I have instantiated this class and set it as DataContext for the entire UserControl:

 

customer = new Customer()
           {
               FirstName = "Gill",
               LastName = "Cleeren",
               BirthDay = new DateTime(1979, 1, 1),
               Email = "gillcleeren@somewhere.com",
               CustomerAddress = null
           };
 
           this.DataContext = customer;

Let’s take a look at what these new features offer us. TargetNullValue can be used in a data binding expression to specify what value should be used in case the binding returns null. In the previous sample, there is no value specified for the CustomerAddress property (it is null). If we want some replacement text, in this case “Unknown”, to be placed instead, we can use TargetNullValue like so:

<TextBlock x:Name="AddressTextBlock" Grid.Row="4" Grid.Column="0" 
    Text="Address:" FontWeight="Bold"></TextBlock>
<TextBlock x:Name="AddressValueTextBlock" Grid.Row="4" Grid.Column="1" 
    Text="{Binding CustomerAddress, TargetNullValue=Unknown}" ></TextBlock>

StringFormat can be used to format the value, just as was shown with the Converter earlier. For example, if we want the BirthDay to be formatted as a date in MM/dd/yyyy format, we can do so using the following code:

<TextBlock x:Name="BirthDateTextBlock" Grid.Row="2" 
    Grid.Column="0" Text="Birthday:" FontWeight="Bold"></TextBlock>
<TextBlock x:Name="BirthDateValueTextBlock" Grid.Row="2" Grid.Column="1" 
    Text="{Binding BirthDay, StringFormat=MM/dd/yyyy}"></TextBlock>

Finally, the FallbackValue can be used to display a value when the data-bound property on the source can not be located. In other words, this value will be displayed when we make an error in that we are trying to bind to a non-existent property. This is shown using the following code:

 

<TextBlock x:Name="InfoTextBlock" Grid.Row="5" 
    Grid.Column="0" Text="Info:" FontWeight="Bold"></TextBlock>
<TextBlock x:Name="InfoValueTextBlock" Grid.Row="5" Grid.Column="1" 
    Text="{Binding Info, FallbackValue=Nothing}" ></TextBlock>

The final result is shown below:

image

The complete code sample can be downloaded here: DatabindingInSL4.zip (64.44 KB)

Note: these new data binding features are a Silverlight 4 feature only!

  Posted on: Friday, December 04, 2009 12:02:03 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 2, 2009    

Silverlight is, as you probably know, a web technology. Basically, we have two choices to add Silverlight to a page (be this page ASP.NET, HTML, PHP or what have you):

  • Screen-filling Silverlight application
  • Silverlight “islands”: small piece(s) of Silverlight embedded on a webpage

Silverlight 4 adds a new option for bringing together Silverlight and HTML by means of the WebBrowser control. If you have done WinForms development, you may remember a similar control in that area as well. It basically allows us to display HTML content inside a Silverlight application.

For some scenarios, this is a very interesting addition to the platform. Imagine you are building a Silverlight application that’s actually a migration of an ASP.NET application. To cut costs, you must perform this migration in several parts. Instead of requiring that all the functionality is converted to Silverlight in one go, you can opt to leave some part in ASP.NET for the time being and still integrate it in the Silverlight environment.

As said, the control available for this, is the WebBrowser control.  The following properties are the most important ones when working with the WebBrowser control: 

· Source: gets or sets the URI that should be rendered in the WebBrowser control

· Navigate: specifies the URI that should be loaded in the control (works identical to the Source property)

· NavigateToString: you can also display an on-the-fly generated string of HTML. This can be done using this method.

The WebBrowser control only works when the Silverlight application is running out-of-browser. If we try running it in-browser, we’ll see a rectangle saying that the HTML is disabled.

image

If we’re running this sample out-of-browser and navigate to this very site (www.snowball.be), we’ll see the following:

image

Let’s now take a look at some code to create this.

The following is the declaration of the WebBrowser control itself:

<WebBrowser x:Name="MainWebBrowser" 
            Width="800" Height="600"></WebBrowser>

In the code-behind, in the click event of the Go-Button at the top, we can send the WebBrowser control to the requested page:

private void AddressButton_Click(object sender, RoutedEventArgs e)
{
    if (Application.Current.HasElevatedPermissions)
        MainWebBrowser.Navigate(new Uri(AddressTextBox.Text));
    else
    {
        string localIFrame = 
                "<HTML><HEAD></HEAD><BODY><IFRAME width='100%'      
                height='100%' src='" + AddressTextBox.Text + "' /></BODY></HTML>";
                MainWebBrowser.NavigateToString(localIFrame);
    }
}

As you can see, there are 2 implementations of the navigation. Why is that? When running out-of-browser, the WebBrowser control works, BUT it can only navigate to pages within the same domain as where the Silverlight application is hosted. To navigate to an external page (that is on another domain), the Silverlight application needs elevated permissions: it must be a Trusted Application. ( We’ll look at Trusted applications in a future post). This is reflected by the first check.

Now there’s a little workaround this limitation and that’s adding an IFRAME control manually and hosting the external page in there. This is done in the else-block.

Note: this is a Silverlight 4 feature which only works in Visual Studio 2010!

The sample can be found here.

  Posted on: Thursday, December 03, 2009 12:46:46 AM (Romance Standard Time, UTC+01:00)   |   Comments [1]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     December 1, 2009    

Question: how many times a day do you move things around in your PC environment? Placing a file on your desktop, picking it up and moving or dragging it into a folder is something we all know and do constantly. Also, personally, I often drag a file into a window to trigger the application to do something with it. Often when I’m doing some quick editing, I drag an image onto Photoshop’s desktop icon. Or when I want to send a mail with an attachment, I drag the file into the window. The application gets a handle to the file and knows what to do with it.

Silverlight applications could not be the target of a drag and drop operation. It was possible to drag stuff around inside the Silverlight window, but it was not possible to drag things into the window running Silverlight. Things changed in this area with the arrival of Silverlight 4. At the time of writing, it’s only possible to drag in one file or a list of files, however dragging in a directory is not supported. This feature is available on Windows and Mac.

Any UIElement within Silverlight can now be the target of a drag operation. IThe UIElement class now defines several events to support dragging, namely DragEnter, DragLeave, DragOver and Drop. DragEnter, DragLeave and DragOver can be used for example to highlight a control when content is being dragged over it. The Drop event fires when an object is dropped onto the UIElement. Let’s take a look at a sample.

Imagine we are building an application in which the user can drag and drop images on a canvas. The way the Canvas needs to be declared is as follows:

<Canvas x:Name="DropCanvas" AllowDrop="True" Drop="DropCanvas_Drop" >

In code-behind, we should handle the Drop event to react to a file being dropped on the UIElement.

private void DropCanvas_Drop(object sender, DragEventArgs e)
{
    IDataObject dataObject = e.Data;
    Point dropPoint = e.GetPosition(DropCanvas);
    if (dataObject.GetDataPresent(DataFormats.FileDrop))
    {
        FileInfo[] files = (FileInfo[])dataObject.GetData(DataFormats.FileDrop);
        
        if (files.Length > 0)
        {
            if (files[0].Extension == ".jpg")
            {
                //only take file 0
                System.Windows.Media.Imaging.BitmapImage bitmapImage = 
                    new System.Windows.Media.Imaging.BitmapImage();
                bitmapImage.SetSource(files[0].OpenRead());
                Image newImage = new Image();
                newImage.Source = bitmapImage;
                newImage.Width = 200;
                newImage.Height = 200;
 
                newImage.SetValue(Canvas.TopProperty, dropPoint.Y);
                newImage.SetValue(Canvas.LeftProperty, dropPoint.X);
 
                newImage.Stretch = Stretch.Uniform;
                DropCanvas.Children.Add(newImage);
            }
        }
    }
}

This event defines a DragEventArgs parameter, which defines a Data property, of type IDataObject. We can access the file or files using the GetData method. This method returns an array of FileInfo objects and these files can then be read out. The code for this is shown below.

We check if the file is an image (check for the file extension) and if it is, we create a new BitmapImage, passing in the dropped file. After that, we create a new Image control and set its source to the BitmapImage instance.

Note: this is a Silverlight 4 feature and the sample only works with Visual Studio 2010!

The complete code can be downloaded here: DragAndDrop.zip (29.78 KB)

  Posted on: Wednesday, December 02, 2009 12:42:41 AM (Romance Standard Time, UTC+01:00)   |   Comments [2]
         
Gill Cleeren     .net | Silverlight | Silverlight Advent Calendar | sl4     November 30, 2009    
Here’s the first article of the Silverlight Advent Calendar! We are starting quite easy…
 
While browsing through the new properties and types available in Silverlight, I came across this nice little new property on the TextBlock called TextTrimming. As the word says, it helps you with showing an ellipsis when the text is too wide for the TextBlock you want it to appear in.

Let’s take a look at this property in action. Suppose we have a TextBlock that has a specific width set to it. On this TextBlock, we specify the TextTrimming property to have the value WordEllipsis.

   1: <TextBlock Text="Hello, my name is Gill Cleeren" 
   2: Width="150" TextTrimming="WordEllipsis"></TextBlock>

Without the TextTrimming property, the result is the following. As you can see, the text is cut of where the TextBlock ends.

image

However, with TextTrimming enabled, Silverlight calculates where it should be placing the ellipsis, making the result look much more polished.

image

Note that is a Silverlight 4 only feature, which only works with Visual Studio 2010!

Tomorrow, we’ll be looking at… Oh can’t say, that has to be a surprise until tomorrow! You can’t go peeking in that advent calendar!

  Posted on: Tuesday, December 01, 2009 12:02:45 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     Silverlight | sl4 | Silverlight Advent Calendar     November 30, 2009    

December is a month of festivities, presents and great food. With Christmas just around the corner, the year has been flying by even faster than the previous one.

To go out with a bang (or should I have said bing…), I have decided to come up with something special called “the Silverlight Advent Calendar”. As probably, many of you don’t know what an advent calendar is as it is something only known in some cultures, let’s start with a little explanation I found on Wikipedia:

An Advent calendar is a special calendar which is used to count or celebrate the days of Advent in anticipation of Christmas. Some calendars are strictly religious, whereas others are secular in content.

Today, most advent calendars are made for children. Many take the form of a large rectangular card with many "windows", one of which is opened every day during Advent. In less elaborate calendars, each window opens to reveal an image, a poem, or part of a story such as the Nativity story itself. More elaborate Advent calendars have a small gift concealed in each window, such as a toy or a chocolate item.

Here are some examples:

advent-calendar

2007-11-26-advent

However, in my calendar, there’s no chocolate for every day you open it! I have something much better… Each day, starting December 1st, I will be posting a Silverlight article here on www.snowball.be. That’s right, a free article on Silverlight for every day you stop by! You don’t even have to open a little door or something to get a free gift!

Christmas must be early this year!

Disclaimer: I HOPE to be able to post each day, as December is a very busy month for me…

  Posted on: Monday, November 30, 2009 11:18:21 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
         
Gill Cleeren     Efficiency | PDC | Silverlight | sl4     November 18, 2009    

Remember my post on printing in Silverlight 3, using the WriteableBitmap. This class allowed to export UI elements to an image and print from there. While it was working, it wasn’t a great way of doing things.

Silverlight 4 brings real printing to the table. All printing is done using the PrintDocument class. In it’s PrintPage event, we can specify what content needs to be printed. This can be the entire screen, a control that’s part of the visual tree or even a control that’s generated on the fly. Finally, we use the Print() method to perform the actual printing of the document.

Let’s take a look at some really easy code to do all this.

The UI code is kept simple intentionally:

    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock Height="25" HorizontalAlignment="Left" Margin="62,92,0,0" Name="textBlock1" Text="I want to print!" VerticalAlignment="Top" Width="194" FontWeight="Bold" FontSize="15" />
        <Button Content="Print" Height="55" HorizontalAlignment="Left" Margin="62,213,0,0" Name="PrintButton" VerticalAlignment="Top" Width="216" Click="PrintButton_Click" />
    </Grid>

This looks like the following:

image

In the click event of the button, we write some printing code.

 

        private void PrintButton_Click(object sender, RoutedEventArgs e)
        {
            PrintDocument document = new PrintDocument();
            document.PrintPage += (s, args) =>
                {
                    args.PageVisual = LayoutRoot;
                };

            document.Print();
        }

This will now show a print preferences dialog, in which we can select a printer. The result in this case is the entire UI being printed, because LayoutRoot was specified.

We can also hook into the beginning and ending of the printing process using the StartPrint and EndPrint event. These can be used to execute some code at the start or ending of the printing process.

  Posted on: Thursday, November 19, 2009 12:38:20 AM (Romance Standard Time, UTC+01:00)   |   Comments [3]
         
Gill Cleeren     Efficiency | Silverlight | sl4     November 18, 2009    

Today at the PDC09, Microsoft announced Silverlight 4, the 4th version of the RIA platform.

You can get the bits here:

  • Visual Studio 2010 Beta 2 or Visual Web Developer Express 2010 Beta 2 (pick one)
  • Silverlight Tools for Visual Studio 2010
  • Expression Blend for .NET 4 Preview – for authoring Silverlight 4 and WPF 4 applications
  • WCF RIA Services (formerly .NET RIA Services) (NOTE: This is actually included in the SL Tools for Silverlight 4)
  • Silverlight 4 SDK CHM (offline documentation) – optionally online here as well
  • Updated Silverlight Toolkit for Silverlight 4
  • Developer runtimes: Windows and Mac platforms
  • Silverlight 4 SDK only – not needed if you install the tools above
  • Silverlight Media Framework – a new, Open Source media player framework for you to use.
  • (This list was shamelessly copied from Tim Heuer’s blog post on Silverlight 4)

      Posted on: Wednesday, November 18, 2009 7:30:30 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Silverlight | TechEd     November 15, 2009    

    At TechEd Europe 2009, together with my colleague Bart Wullems, I did a TechEd Online TechTalk on Building Real World Silverlight applications. You can watch it here: http://www.msteched.com/online/view.aspx?tid=298625e9-142f-4b7f-8018-81615efd51c4 

    A second one on building multitouch applications, together with a fellow Regional Director Daron Yondem, will be online soon.

      Posted on: Sunday, November 15, 2009 10:09:05 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Events | Silverlight     September 29, 2009    

    Last week, Silverlight FireStarter was hosted, an in-person and also online event where top speakers like Scott Guthrie, Brad Abrams, Tim Heuer etc talked about all there is to know about Silverlight.

    Luckily, all the sessions can now be seen on-demand for free here: http://www.msdnevents.com/firestarter/

    A small extra: I just found through Tim Heuer a nice 2-part video on Visual Studio called the Visual Studio Documentary form Channel9:

    Welcome to the first installment of the Visual Studio Documentary.This is an hour long documentary that is split into two parts, roughly a half hour each. Welcome to part one, where we take you back to the days of MS-DOS and Alan Cooper who originally sold Visual Basic to Bill Gates back in 1988.  Next week we will feature Part Two but for those that would like to watch it sooner, here is Part Two. In addition, each week we will post a longer and more in-depth stand alone interview from the interviewees that were featured in the documentary.

    Links: http://channel9.msdn.com/shows/VisualStudioDocumentary/The-Visual-Studio-Documentary-Part-One/ and http://channel9.msdn.com/shows/VisualStudioDocumentary/The-Visual-Studio-Documentary-Part-Two/

      Posted on: Wednesday, September 30, 2009 12:32:51 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Events | Silverlight     September 29, 2009    

    Today, the Belgian edition of Mix, ReMix09, took place in Belgium. With an almost sold out conference, the expectations were high, many people were expecting to learn new things on the tools and technologies that will influence how we work in the coming years. Silverlight, Expression Blend & Design, Surface… were covered in today’s sessions. Some corporate speakers, including Brad Abrams (who joined Visug yesterday for another sold out event) and Adam Kinney.

    The event

    After a long absence from Kinepolis in Brussels, the troops again gathered in the largest cinema complex in Belgium. Like said in the introduction, the event was almost completely sold out, which was noticeable in the keynote: almost all chairs were taken and at that very point, the highway around Brussels was still completely stuck.

    Because of the fact that it’s a cinema complex, the rooms themselves are the best to do presentations in and also to watch them in.

    All attendees could get a trial version of Blend, which I noticed were very much wanted.

    The speakers

    Most of the content today was brought by corporate speakers, giving attendees a deep insight in the technologies that were covered. These included Silverlight, Surface, Blend and ASP.NET MVC. What struck me somehow, is that there where more questions after sessions than normal: Belgian audience is not very communicative, however today, quite some questions were asked.

    The keynote was delivered by Katrien De Graeve and Luc Van De Velde. It was clear, to the point and had a nice flow of ideas in it. Good work, guys!

    The technologies

    Two things really amazed me today. First, when Luc asked during the keynote, how many people attended last year’s Mix Essentials, only an estimated 5-10% raised their hand. I can’t think of an explanation for this though…

    The other thing is the following: the people that attended the conference, had very little knowledge of the Silverlight and Blend tools. OK, you can think: that’s why they came to the conference, right?! True, but still, I would have expected that more people would have experimented with the Silverlight tools.

    The pictures

    I took my camera with me today (for once I actually didn’t forget to do so…) and here are some of the pictures. The full album can be found here: http://www.flickr.com/photos/gillcleeren/sets/72157622483133184/

    Ordina@ReMix

    A nice video testimonial for Ordina was shown in the keynote where I talk about WPF projects we have done in the past few months. The video will be added soon here!

      Posted on: Wednesday, September 30, 2009 12:23:18 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     September 27, 2009    

    When upgrading to Silverlight 3, the Stock Trader reference implementation that comes with the Prism (aka Composite Application Guidance) doesn’t work anymore.

    This is caused by the fact that the upgrade tool in Visual Studio changes the access modifier for the resource files in the upgrade process. While the upgrade itself works, as soon as you run either the Silverlight or the WPF app, you’ll get an app crash, like so:

    image

    This is caused by the “RealEstateListingViewer.Strings.resx” and the “RealEstateListingViewer.Strings.Designer.cs” file: Silverlight removed the public constructor for the RealEstateListingViewer_Strings class, which it needs to instantiate this class from XAML.

    To solve the error, in the RealEstateListingViewer.Strings.Designer.cs file, change the internal constructor to public:

     [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
            public RealEstateListingViewer_Strings() {
            }
      Posted on: Sunday, September 27, 2009 11:00:47 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     August 4, 2009    

    2009 is another PDC year, the second one in a row. Where PDC 2008 saw the birth of Windows Azure, PDC 2009 will be marked with erhm… Well, we never know with a PDC, so wait and see!

    Since today, registration for the event is open here. Also, a list of 30 sessions has already been announced as well. One that struck me the most is this one: http://microsoftpdc.com/Sessions/P09-11

    Microsoft Silverlight Roadmap and Futures by Karen Corby

    With Silverlight 3 shipped earlier this year, the team is working on what comes next. In this session, we’ll give you an early preview of the roadmap for Silverlight, and offer a sneak peek at some of the features that we’re considering as part of the next release.

    Yes, this means that we’ll at least get to see a glimpse of Silverlight vNext this fall.

      Posted on: Tuesday, August 04, 2009 9:10:03 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     July 30, 2009    

    Probably the most requested feature for Silverlight 3 was being able to print or export the contents of a control so that we can save it and then print it. While there is no Print class of some sort directly available in Silverlight 3 either, we can print, using some small workaround. And that workaround goes by the name of the WriteableBitmap.

    In this sample, I have created a very simple DTP application (desktop publishing application). It allows the user to draw on a Canvas, add some text and some images. After that, he can print the result. There is room to improve, but it should get you on your way when trying to print from Silverlight 3.

    This is the UI of the application.

    image

    Let’s take a look at how it was done. The XAML code for this sample is quite simple. The Canvas called DrawingCanvas is the one we want to export and print its contents.

                <Grid x:Name="GridApplication">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid x:Name="GridHeader" Background="#47659e" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
                        <TextBlock Foreground="White" Margin="2, 0, 0, 0" FontWeight="Bold">
                        Printing from Silverlight 3
                        </TextBlock>
                    </Grid>
                    <StackPanel x:Name="ButtonStackPanel" Grid.Row="1" Grid.Column="0" Background="#efedeb">
                        <Rectangle Fill="Black" Height="40" Width="70" Margin="2"></Rectangle>
                        <Button x:Name="ButtonRectangle" Content="Add rectangle" Margin="3" Click="ButtonRectangle_Click" HorizontalAlignment="Center"  ></Button>
                        <Ellipse Fill="Black" Height="40" Width="70" Margin="2"></Ellipse>
                        <Button x:Name="ButtonEllipse" Content="Add Ellipse" Margin="3" Click="ButtonEllipse_Click" HorizontalAlignment="Center"></Button>
                        <Image Source="pictureicon.png" Width="70" Margin="2" Stretch="Uniform"></Image>
                        <Button x:Name="ButtonImage"  Content="Add image" Margin="3"  Click="ButtonImage_Click" HorizontalAlignment="Center"></Button>
                        <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Center">
                            <TextBlock Text="T" FontSize="30" FontWeight="Bold" Margin="2" FontFamily="Courier New"  ></TextBlock>
                        </Border>
                        <Button x:Name="ButtonText" Content="Add text" Margin="3" Click="ButtonText_Click"  HorizontalAlignment="Center"></Button>
                        <Rectangle Height="1" Width="130" HorizontalAlignment="Center" Fill="DarkGray" Margin="5"></Rectangle>
                        <Button x:Name="ButtonCreate" Content="Create poster" HorizontalAlignment="Center" Click="ButtonCreate_Click"  Margin="3"></Button>
                        <Button x:Name="ButtonSave" Content="Save poster" HorizontalAlignment="Center" Margin="3" Click="ButtonSave_Click"></Button>
                    </StackPanel>
                    <Canvas x:Name="DrawingCanvas" Grid.Row="1" Grid.Column="1" Width="648" Height="578" Background="#bbbbbb">
    
                        
                    </Canvas>
                </Grid>

    As said, the class that makes printing possible, is the WriteableBitmap. We pass in the control we want to “render” and an arbitrary transform.

    WriteableBitmap wb = new WriteableBitmap(DrawingCanvas, null);

    Then, we use Joe Stegman’s PNG Encoder. It allows us to create PNG images on the fly. Note that, like mentioned on Joe’s blog, this encoder is not optimal and can be improved both in speed and compression size. We create an instance of the EditableImage class, giving it the size of the control we want to render.

    editableImage = new EditableImage((int)DrawingCanvas.ActualWidth, (int)DrawingCanvas.ActualHeight);

    At this point, we can start doing a pixel-by-pixel copy of the “canvas-data” to the EditableImage.

    Converter cl = new Converter();
    for (int idx = 0; idx < editableImage.Height; idx++)      // Height (y)
    {
        for (int jdx = 0; jdx < editableImage.Width; jdx++) // Width (x)
        {
            if (wbCounter == wb.Pixels.Length)
                break;
            byte[] colorBytes = cl.ConvIntegertoByteArray(wb.Pixels[wbCounter], 3);
            editableImage.SetPixel(jdx, idx, colorBytes[0], colorBytes[1], colorBytes[2], 255);
            wbCounter++;
        }
    }
    The image data is now in memory, we can now export and print it using a simple stream and the Silverlight 3 SaveFileDialog.

    SaveFileDialog dialog = new SaveFileDialog();
    dialog.DefaultExt = "png";
    
    if (dialog.ShowDialog() == true)
    {
        using (Stream fs = (Stream)dialog.OpenFile())
        {
            Converter c = new Converter();
            c.CopyStreamContents(editableImage.GetStream(), fs);
            fs.Flush();
        }
    }

    The result is a generated PNG file, ready to print! The complete sample code can be downloaded here.

    kick it on DotNetKicks.com
      Posted on: Thursday, July 30, 2009 9:20:26 PM (Romance Daylight Time, UTC+02:00)   |   Comments [2]
             
    Gill Cleeren     Silverlight | Twitter     July 23, 2009    

    I’m currently creating a Silverlight Twitter client and ran into an error that seems quite well known when developing against the Twitter API, namely the 417 Expectation Failed error or status message.

    The solution is – and this works with the WebClient as well as the WebRequest – adding the following line before making the call to Twitter:

    ServicePointManager.Expect100Continue = false;

    This is not needed for every request: if you are for example adding a status update over the API, then you need to add it. If you are simply requesting a list of messages (friends timeline for example), it’s not needed. So far, everything was OK with my app as well.

    However, if you only add it to the places where it’s needed (like said when adding a status) and omitting it in other places, will cause the same error. Turns out that a status update will fail with the same message if you have in the same session queried a list without setting the Expect100Continue.

    Bottom line of this story: always set it. It will make your life easier!

      Posted on: Thursday, July 23, 2009 2:52:53 PM (Romance Daylight Time, UTC+02:00)   |   Comments [2]
             
    Gill Cleeren     Efficiency | Silverlight     July 14, 2009    

    I just showed you Sobees… If that is not enough Silverlight showcase for your taste, don’t fear, there’s more! On the Microsoft case study site, available via www.microsoft.com/casestudies, no less than 8 new showcases with Silverlight have been added. These include the following;\

    • Digital Minds Ltd; Financial Site Transforms Online Investing with Interactive Tools
    • Yahoo! JAPAN: Yahoo! JAPAN Finds Unique Solution for Multiplatform Online Video
    • TDK-Lambda: Electronics Manufacturer Reinvigorates BI Application with New Interface
    • netlinkblue: Rich Media Platform Delivers Powerful Results for Fans of New Cricket League
    • National Instruments: Cross-Platform Plug-In Powers Rich Internet Applications for Scientists and Engineers
    • NASA: NASA Provides Interactive, 3-D Views of the Next Mars Rover to the Public
    • ninemsn: Australian Web Site Gives Visitors a “Wow” Experience with Rich Media Platform
    • Signposter.com: Advertising Company Doubles Customer Base in Six Months with Mapping Solution
    • Kimberly-Clark: Kimberly-Clark Migrates Consumer Site to New Web Platform for High Value, Lower Cost
    • Continental Airlines: Continental Airlines Modernizes Call Center Application with Web-Based Technology

    However you put it, the adoption rate of Silverlight is increasing and it is increasing rapidly. The fact that so many large customers are choosing Silverlight for their mission-critical sites and applications confirms their trust in the technology as well.

    A few days back, someone was asking me about the install base of Silverlight and whether or not I see this as a problem. There are 2 things I can say to that:

    • The install base is increasing every day.
    • Large companies switching to Silverlight will increase the install base, which in turn will increase the number of companies choosing for Silverlight, which in turn… You get the picture.
      Posted on: Tuesday, July 14, 2009 3:50:14 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Silverlight     July 14, 2009    

    Now that Silverlight 3 is released, a bunch of great applications using the functionalities of the platform are starting to pop up. One of them is the new Twitter client from Sobees, available via www.sobees.com. Created entirely in Silverlight, this offline application allows you to view the tweets from the people you are following, as well as searches within Twitter. At this point, Facebook is not yet supported, but it coming soon.

    The user interface is pretty impressive, keeping in mind it’s only an alpha release at this moment. It’s scattered with nice touches, one of them being the characters-left countdown, shown when adding a new Tweet.

    Developers might be thinking; how was this created? As you may know, some time ago, Twitter closed their borders in terms of cross domain access. Their crossdomain.xml file is pretty strict (not to say completely locked down). The consequence of this move is that client-side platforms like Silverlight, can’t connect with the platform directly, because of cross domain restrictions, active in Silverlight. The solution for this problem is normally building an extra service on your own domain, let this service connect with the external service and let Silverlight connect with your own service. Services don’t mind the cross domain policies in place.

    Sobees did more or less the same, otherwise their client could not connect with Twitter. They are using Azure as their service platform: the Sobees client connects with Azure that in turn connects with Twitter. It is in the end a large mashup using Twitter, Azure and Silverlight 3.

    Next to the Sobees Silverlight application, they also have bDule, a desktop variant of the Twitter client, created entirely in WPF.

    All the goodness can be downloaded via www.sobees.com and www.sobees.com/bdule , of course all free of charge!

      Posted on: Tuesday, July 14, 2009 11:47:42 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Silverlight     July 10, 2009    

    This “Silverlight 3 Launch Video” on Channel 9 really made my evening, it’s hilarious!
    Why is Dan Fernandez crawling around on a concrete floor with a blonde wig while White Snake plays in the background?  That's a great question and I wish I had a logical answer but I don't so I will just give you the truth.  It has to do with Silverlight, Expression and couple's therapy.  I hope you enjoy and good luck.
    http://channel9.msdn.com/shows/History/Silverlight-3-and-Expression-3-Launch-Video-well-sort-of-/

      Posted on: Friday, July 10, 2009 11:17:24 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Microsoft | Personal | Silverlight     June 10, 2009    

    I've been a Microsoft enthusiast for many years now, as many of you probably know. Honestly, I haven't worked on a Linux-based computer ever, and apart from an IPod, I haven't worked with any Apple products either. Why? I like Microsoft products, I really do. They have served me well and I have never had any feeling that I could be better off using something else. Thanks to their products, I have a great career going on. I have had countless sleepless nights because I want to try that one special thing. I even got to know my girlfriend better through the use of Microsoft's IM solution before we were together.

    And still, there's a lot to look forward too. In fact, I think we are at a turning point at this moment. Many great products and technologies are on the verge of being released or are already on the market that will give Microsoft a new and improved image.

    Look at Bing, the new search engine launched last week. It is a new way of searching, not a direct competition aimed at what is already out there. But it is innovative, it is fresh, it is cool. Try it, you'll be amazed with what it has to offer!

    Also last week, Project Natal was shown at E3. Again a very innovative product. Not that long ago, Microsoft released the Surface, which was perhaps the start of this innovative period.

    The advertising campaigns Microsoft is currently doing, sadly not here in Europe, using Seinfeld and Bill Gates were hilarious. "I'm a PC" is now a real brand. It makes people proud of the PC they are using. The more recent campaign, aimed at the lower cost for using a computer against Apple, was the second hit in a row.

    Looking a bit more at the professional market, we see many great improvements being done on tools and technologies. The next version of Silverlight that will be released somewhere this year, includes some great improvements, making it a truly business-ready platform. Yes, you can build enterprise applications on Silverlight today.

    The next release of Visual Studio promises another great step forward in developer productivity. Using the same tools for all technologies and projects, from BI to enterprise applications to games, it can all be done in VS2010. There are many new features in the new version that will make you do more in less time. In this time of a worldwide recession, that can't be but good news.

    Finally, the biggest release that Microsoft is doing this year, is of course Windows 7. With a development cycle not plagued by any issues like Windows Vista's, the product is almost ready. Many customers already tested the new OS in what is probably one of the biggest beta tests ever. And perhaps also one of the most positive ones. Almost all feedback and reviews so far have been nothing but positive about the new OS. A lot of customers are already using it today in RC format for their production needs, which means they fully trust the project.
    Although I've been using Windows Vista from day 1, I've never understood the criticism about the product. I think it was "cool to say that Vista wasn't any good". Now, the new cool will be using Windows 7!

    As mentioned in the beginning, for a guy like me, the future of Microsoft has never been brighter.

      Posted on: Wednesday, June 10, 2009 2:28:02 PM (Romance Daylight Time, UTC+02:00)   |   Comments [7]
             
    Gill Cleeren     Silverlight | Slide decks     May 19, 2009    

    Today was the ninth incarnation of Multi Mania here in Belgium. What started out as a small event, is now a huge 2 day convention on media and animation. I was asked again to introduce the attendees to Silverlight (V3 this year of course).

    The talk, which was sadly only 45 minutes, included an overview of the most important new features in Silverlight 3, including out-of-browser support (which opened many attendees' eyes ;-)), local messaging, Bitmap API's and pixel shaders.

    You can download the slide deck here.

    Thanks for attending!

      Posted on: Tuesday, May 19, 2009 10:30:14 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight | Visual Studio.net     May 18, 2009    

    The wait is over. The biggest release of Visual Studio is here… at least in a beta form. Visual Studio 2010 is probably the most remarkable release of Microsoft’s flagship IDE since the introduction of .NET, now already 8 years ago (if I count correctly… man, I AM getting old!!).
    You may be wondering; why is this release any bigger than the previous ones? Well, for one thing, the complete shell is now written in WPF. It supports dual screen setups. It includes .NET 4.0. It will support a Silverlight 3 designer. It will even make coffee for you!

    ctp

     

    If you want to get started with this beta version, head over to MSDN subscriptions (yes, subscriber download only!).

      Posted on: Tuesday, May 19, 2009 12:27:54 AM (Romance Daylight Time, UTC+02:00)   |   Comments [2]
             
    Gill Cleeren     Silverlight     May 17, 2009    

    The SQL Server team created a cool looking calculator in Silverlight, called the SQL Server Value Tool.

    17-05-2009 23-43-19

    It can be seen here.

      Posted on: Sunday, May 17, 2009 11:44:59 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Silverlight     April 22, 2009    

    Silverlight adoption is growing everyday, both the install base and the number of large customers making the switch to Silverlight. This weekend, another one made the plunge into the Silverlight world: www.IPLT20.com , the official website of the Indian Premier League of cricket. Cricket may not be big here in Belgium where I live, but it is enjoyed by people in more than 120 countries around the world, including India, Pakistan, South Africa, Hong Kong, Singapore, Australia, New Zealand, United Kingdom and even the US. In India, it's even the most watched sport on television.

    Since they are using Silverlight, they can offer their many visitors a much richer experience, including interactive statistics and scoreboard display, ball-by-ball commentary, match highlights simultaneously available using picture-in-picture, and a rich, immersive photo gallery using deep zoom.

    The site offers access to more than 500 hours of live and on-demand video, has 50.2 million page views in six weeks and expects to to reach 400 million page views, 10 million unique users and 45 million visits during the upcoming season.

     

      Posted on: Wednesday, April 22, 2009 11:39:55 AM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
             
    Gill Cleeren     Efficiency | Events | Silverlight | Mix 09     March 30, 2009    

    Now that Mix is over, it’s time to write a rather large post on the event that took place last week in Las Vegas for the 4th time. The 5th edition is already announced (Mix10 I guess), it will take place March 15-17, in Las Vegas at Mandalay Bay (up until now, Mix has always been at the Venetian).

    Was Mix09 a good edition, compared to previous ones? Absolutely! At Mix06, the first year the conference was held, the main focus was on ASP.NET Ajax, which allowed “at that time” writing richer and more compelling user experiences. Mix07 was of course marked by the announcement of Silverlight 1.0 beta and 1.1 alpha (which would later become Silverlight 2). A year later, at Mix08, Silverlight 2 officially reached beta status. And this year, Silverlight 3 arrived in beta. Silverlight 3 is looking at a release date later this year.

    However, not only Silverlight was the star of the show: the second day of the event was marked by the RTW of IE8, the all-new version of the popular browser. After a long road, the new browser is here and it contains a number of interesting new features, which I’ll cover later in this post.

    Mix09: the event. Now on DVD!
    If you didn’t have the time, money… to attend the event in real life, don’t fear. All sessions are recorded by Microsoft AND are available for free on the Mix09 website. If you want to get your modem hot from all the downloading, head over to http://videos.visitmix.com/MIX09 for all videos of the event. Note that you should plan to take some days off work to see them all, there’s more than 120 videos online. Check out Mike Swanson’s blog for a complete list of the sessions, a batch file to download all sessions and a batch renamer for all content (http://blogs.msdn.com/mswanson)

    Also, many speakers have uploaded their demos to their blogs, so be sure to check them out.

    Silverlight 2 + 1 = Silverlight 3

    Star of the show was of course Silverlight 3. The released version is a beta, not yet feature complete, meaning that some parts of the software that will be in the final version aren't there yet at this point. All the necessary tools and SDKs are available, you can find the link below. A very important note: if you are developing Silverlight 2 applications, you should not install this release on your production machine, because it makes your setup a Silverlight 3 config. Currently, Silverlight 3 apps are incompatible with Silverlight 2. A virtual machine might be the best option here. 

    Out-of-browser

    One of, if not the biggest feature of this new release is out-of-browser support. It allows you to place your application directly on the customer's machine, enabling an off-line experience that's the same as the online experience. All this becomes possible without any additional download of runtime or the need to write applications in a different way. Any Silverlight application that is out-of-browser enabled, can now be easily found on the user’s desktop or start menu, and launched with a single click. Also, it can test if the network is connected, update itself and also has access to Isolated Storage. The API for this is very easy, I'll be writing an article on this soon.

    Is this any different from Adobe Air, which enables an offline experience as well? Yes it is. Air needs a separate runtime which is about 20mb in size and provides access to the entire hard drive of their customer’s computer, which can be a significant barrier if the customer does not have complete trust.

    Also, the adoption rate for Air is well below the rate for Silverlight. So far, Silverlight has an install base of about 300 million, since its launch about 5 months ago. Microsoft estimates that about 400.000 developers and designers are currently using Silverlight already.

    Silverlight for Eclipse

    Up until now, the Silverlight tools were mainly aimed at Visual Studio developers. Microsoft now also has a Silverlight plugin for Eclipse, called Eclipse Tools For Silverlight (Eclipse4SL). This way, Mac developers can join in in developing Silverlight applications as well. The current version is a CTP.

    Expression Blend 3

    While not only targeting Silverlight, the release of Expression Blend 3 is great news for Silverlight developers and designers, offering full compatibility and support for Silverlight 3 effects, along with integration with Visual Studio 2010 and WPF. One of my favorite features is the Photoshop and Illustrator import, enabling smooth integration with workflows already in place. During the import process, designers have the freedom to view and import Photoshop files layer by layer. Layers can be easily regrouped and elements retain their original formats, layers, layer positions, editable text and vectors.

    Another great feature in Blend 3 is SketchFlow, a way for rapid application prototyping. Using SketchFlow, designers can rapidly map out and experiment with the UI flow of a concept with SketchFlow. Built-in ‘sketchy’ styles enable customers to concentrate on an overall concept of a solution rather than focusing too early on the detail.

    Important feature you may ask for enterprise? Absolutely! Business application experts can use SketchFlow to rapidly explore different UI flows and scenarios for their line of business applications without any technical knowledge of the underlying delivery platform. These ideas can be easily presented via the SketchFlow player which provides the ability to not only interact with prototypes, but also enabling the user to provide in-context feedback using the built annotation capability.

    To download all the tools for Silverlight development, go to http://silverlight.net/getstarted/silverlight3/default.aspx.

    Microsoft Web Platform

    Let's first take a look at what is really meant with this new term, the Microsoft Web Platform. The MWP is the software of choice when building Web solutions or applications for businesses, large or small. If you’re looking to create your company’s global Web presence, building applications for your small business or launching a new Web site, Microsoft has the solutions for you.

    The platform includes several components, including the Web Platform Installer and the Web Application Gallery.

    The Web Platform Installer Includes:

    • Internet Information Services (IIS) 5.1 on Windows XP SP3
    • IIS 6.0 on Windows Server 2003 SP2
    • IIS 7.0 on Windows Vista SP1 and Windows Server 2008
    • SQL Server 2008 Express
    • .NET Framework 3.5 SP1
    • Visual Web Developer 2008 Express Edition
    • IIS Extensions including:
      • IIS 7 Media Services 3.0
      • IIS7 Administration Pack
      • Database Manager for IIS7
      • WebDav 7.5
      • FTP 7.5
      • FastCGI for PHP support on IIS6
      • URL Rewriter
      • IIS 7 Application Routing
      • Web Deployment Tool for IIS
    • ASP.NET and features such as ASP.NET MVC
    • Silverlight Tools for Visual Studio
    • The Community Version of PHP v5.2.9

    The Windows Web Application Gallery is a collection of the most popular Open Source and community Web applications that run on Windows. It provides a simple streamlined way for users to explore, discover, and install ASP.NET, PHP, and other types of web applications and solutions on the Windows Platform.

    More information and all the downloads can be found at: Microsoft Web Platform 

    Azure Services Platform

    While the Azure platform was announced in November last year at PDC, a number of updates to the platform have been released. This shows that Microsoft is committed to delivering a comprehensive cloud platform.

    The following updates were done on Azure:

    • Windows Azure: An update to the Windows Azure service delivers advancements in interoperability,  flexiblity, geo-specification, and the ability take existing IP to the cloud. 
    • Applications written in 3rd party programming languages such as PHP can be deployed and run on the Windows Azure infrastructure with FastCGI support, providing an easy to use, scalable cloud runtime and storage environment while giving developers the power to choose their preferred programming language. For .NET developers, Full Trust is now available so all aspects of the .NET Framework can be utilized, including invoking native and legacy code components and giving existing code investments new life in the cloud.  Over the next few weeks Geolocation will be available, enabling customers to specify the datacenter location for applications and storage to optimize for lower network latency and comply with location-based regulatory and legal requirements. 
    • SQL Services: SQL Data Services (SDS) recently announced an accelerated roadmap to provide a cloud database as part of the Azure Services Platform. 
      • In this updated roadmap, SDS will deliver a fully relational database service in the market to provide customers with the ability to use existing investments in on-premises SQL Server T-SQL development and use a full relational data model in the cloud.  This approach enables greater developer agility and faster time to market by supporting the use of existing applications, tools and knowledge, and featuring distributed, cloud based functionality that will work with other online services or with existing on-premises solutions.  The public availability of these updated service features will be mid-2009 and commercially available later this year.
    • .NET Services: .NET Services makes further enhancements to embrace web standards, interoperability, and provide connectivity on-premises with the cloud, and disparate groups with each other across network boundaries.  These services allow customers to easily federate data and messages with its Service Bus and Access Control services.  By supporting REST, ATOM, JSON, SOAP and HTTP web standards, web developers using any programming language can use the service to connect, collaborate, and create federated applications.
    • Live Services: To accommodate increasing popularity and demand, Live Services was announced at PDC 2008 as an open Community Technology Preview, where any developer can start utilizing the web services and incorporate them into socially-aware applications connecting to 460 million Windows Live users.  We will announce Live Services updates in the future, but have nothing specific to announce at MIX ‘09.

    More info on Azure can be found at Azure Services Platform

    Windows Mobile 6.5

    An updated version of Windows Mobile was also shown at Mix. The most remarkable features are the new version of Internet Explorer Mobile, the addition of Widgets and Windows Marketplace for Mobile.

    Internet Explorer 8

    Finally, Internet Explorer 8 was also released. Internet Explorer 8 takes a big step forward in browser innovation for the way people use the web today. Internet Explorer 8 makes it easier to visit sites you’ve been to before with the new Smart Address Bar and enhanced Favorites Bar, works with your search provider to suggest likely searches based on what you type into the Enhanced Instant Search Box, groups tabs to match the way you browse the web and gives you Accelerators and Web Slices to keep you closer to the sites and services you use every day.

    IE8 is also safer than ever. Specifically, Internet Explorer 8 improves upon our protection against social engineering “phishing” attacks with the new SmartScreen Filter, which helps protect against malware sites and downloads. Internet Explorer 8’s new Cross-Site Scripting filter helps protect users against Cross-Site Scripting Type-1 reflection attacks, one of the most common attacks against Web sites. 

    It's also more reliable than ever. It includes a new Compatibility View mode to help ensure that users can access all the sites they use today without display or functionality issues. Additionally, the new architecture of Internet Explorer 8 helps ensure that a single tab crashing does not cause users to lose their whole browser session, and crash recovery restores the crashed site and content

    Internet Explorer 8 is available on Windows XP SP2 and SP3, Windows Server 2003 SP2, Windows Server 2008, Windows Vista (RTM), SP1 and SP2.

    To download IE8, go to www.microsoft.com/ie8.

      Posted on: Monday, March 30, 2009 11:25:40 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Silverlight | TechDays     March 21, 2009    

    Last week, Microsoft organized the Belgian edition of the Techdays, for the first time in Antwerp. After reading (Twitter, blogs…) and hearing quite a lot of feedback, the event was a success.

    For me personally, it was also an exciting week: for the first time in my career, I was doing a keynote. I presented the Silverlight part of this talk, together with 2 other Regional Directors from Belgium: Peter Himschoot took the WPF part and Grégory Renard handled the Surface. Also, Katrien De Graeve (Microsoft) showed Windows 7 and Azure, while Hans Verbeeck (also Microsoft) glued all bits and pieces into a nice session.

    In this article, you’ll get an overview of the demo we created for the keynote, called “Silverlight on the bike”.

    silverlightonthebike1

    The scenario

    Hans, when not behind his laptop, loves to ride his bike. While on his bike, he wears a small device from Garmin that monitors his heart rate and also retrieves the entire route that he followed via GPS. When combining these 2 bits of information, you can see where the heartbeat went higher (because of a slope for example).

    Garmin must like developers, because they expose this data as XML. Pure clean XML that any developer can read out. This data was the start for our scenario: plot out the route that Hans did on his bike on a map, show the heartbeat on a graph, throw in some pictures he took along the road and expose all this in a familiar looking interface in the browser.

    The demo also needed to run as a standalone application as well as on the surface. Because of the portability of the code between Silverlight and WPF (Surface applications are WPF as well), a large amount of code could simply be copied from one platform to another.

    And here’s how we created it…

    While the demo contains too much code to explain here, I’ll go over some of the most interesting parts that really make Silverlight shine.

    Step 1: Design is everything (sort of…)

    The first thing we did was going to a designer and explain him the needs of our application. A request from our side was of course that he needed to create the interface in Blend. So he came up with a design, completely in XAML, as shown below.

    silverlightonthebike2

    A cool thing when working with Silverlight is a nice workflow between designers working in Blend and developers working in Visual Studio. Since designers work with the same files as developers, there’s no need to cut and paste the work that the designer did: he can make changes while developers are creating their code and these changes will be incorporated without any hassle.

    Step 2: Get me that data

    Design is one thing, coding is another. Our application is built around data (remember the XML file from the Garmin device), so the first problem that needs solving is getting that data into the application. Silverlight 2 supports several ways to connect with data: WCF, webservices, reading remote files… For the sake of simplicity, we are going to use the latter: we’ll drop the XML file in the web application. Silverlight now needs to connect with the file using the WebClient, a class that’s also available in the full version of the .NET framework.

    Whenever Silverlight needs to go out fetching data, it will do so asynchronously. If it would perform this action synchronously, the browser would hang while data flows from server to client or vice-versa.

    Codesnippet 1 shows the code needed for the data access and the result is shown.

       1: WebClient client = new WebClient();
       2:             Uri address = new Uri("http://localhost:" + HtmlPage.Document.DocumentUri.Port + "/" + fileName, UriKind.Absolute);
       3:             client.OpenReadCompleted += client_OpenReadCompleted;
       4:             client.OpenReadAsync(address);

    CodeSnippet 1

    silverlightonthebike3

    Step 3: Let’s parse XML (still yuck?)

    Now that we are able to connect with the data, we need to do something with it, we only have it in a string at this point. We need to parse the XML and create objects that represent the data in memory. Parsing XML using the “traditional” way, using XmlDocument classes and the like, is not my favorite part of my development life. This API is quite difficult and often requires XPath knowledge to access the correct data.

    Since .NET 3.5 (in fact also in 3.0 as beta), LINQ and LINQ to XML were introduced and the great thing is that these are also included in Silverlight. Using the LINQ to XML API, we can very easily parse the XML and create objects representing the data. Codesnippet 2 shows the XML, codesnippet 3 shows the type that we’ll be creating. In Codesnippet 4, the code to parse the XML and to create a generic list of TrackPoint instances is shown.

       1: <Trackpoint>
       2:             <Time>2009-02-14T14:13:10Z</Time>
       3:             <Position>
       4:               <LatitudeDegrees>51.3509752</LatitudeDegrees>
       5:               <LongitudeDegrees>4.6816549</LongitudeDegrees>
       6:             </Position>
       7:             <AltitudeMeters>20.3249512</AltitudeMeters>
       8:             <DistanceMeters>0.0343911</DistanceMeters>
       9:             <HeartRateBpm >
      10:               <Value>111</Value>
      11:             </HeartRateBpm>
      12:             <SensorState>Absent</SensorState>
      13:           </Trackpoint>
      14:           <Trackpoint>
      15:             <Time>2009-02-14T14:13:11Z</Time>
      16:             <Position>
      17:               <LatitudeDegrees>51.3509765</LatitudeDegrees>
      18:               <LongitudeDegrees>4.6816523</LongitudeDegrees>
      19:             </Position>
      20:             <AltitudeMeters>20.3249512</AltitudeMeters>
      21:             <DistanceMeters>0.0000000</DistanceMeters>
      22:             <HeartRateBpm >
      23:               <Value>110</Value>
      24:             </HeartRateBpm>
      25:             <SensorState>Absent</SensorState>
      26:           </Trackpoint>
      27:           <Trackpoint>

    Codesnippet 2

       1: public class TrackPoint
       2:     {
       3:  
       4:         private DateTime _time;
       5:  
       6:         public DateTime Time
       7:         {
       8:             get { return _time; }
       9:             set { _time = value; }
      10:         }
      11:  
      12:         private Point _position;
      13:  
      14:         public Point Position
      15:         {
      16:             get { return _position; }
      17:             set { _position = value; }
      18:         }
      19:  
      20:  
      21:         public double X
      22:         {
      23:             get { return _position.X; }
      24:             set { _position.X = value; }
      25:         }
      26:  
      27:         public double Y
      28:         {
      29:             get { return _position.Y; }
      30:             set { _position.Y = value; }
      31:         }
      32:  
      33:         private int _cadence;
      34:  
      35:         public int Cadence
      36:         {
      37:             get { return _cadence; }
      38:             set { _cadence = value; }
      39:         }
      40:  
      41:         private double _distance;
      42:  
      43:         public double Distance
      44:         {
      45:             get { return _distance; }
      46:             set { _distance = value; }
      47:         }
      48:     } 

    Codesnippet 3

       1: public List<TrackPoint> Load(Stream filename)
       2:         {
       3:             XElement doc = XElement.Load(filename);
       4:             List<XElement> tps = doc.Descendants("Trackpoint").ToList<XElement>();
       5:  
       6:             TrackPoint tp = null;
       7:  
       8:             foreach (XElement point in tps)
       9:             {
      10:                 try
      11:                 {
      12:                     tp = new TrackPoint();
      13:                     tp.Position = new Point(double.Parse(point.Descendants("LatitudeDegrees").First().Value) / 10000000,
      14:                                                          double.Parse(point.Descendants("LongitudeDegrees").First().Value) / 10000000);
      15:                     tp.Distance = double.Parse(point.Descendants("DistanceMeters").First().Value) / 10000000;
      16:  
      17:                     if (tp.Distance > _totalDistance)
      18:                         _totalDistance = tp.Distance;
      19:  
      20:                     tp.Cadence = int.Parse(point.Descendants("HeartRateBpm").First().Value);
      21:  
      22:                     _trackPoints.Add(tp);
      23:                 }
      24:                 catch (Exception)
      25:                 {
      26:                         
      27:                    
      28:                 }
      29:             }
      30:             return _trackPoints;
      31:         }

    Codesnippet 4

    Step 4: Design: OK! Data: OK! UI: To Do!

    Now we have the data from the device ready on the client-side within our Silverlight application as a generic list. We can now go ahead and add the UI elements to the interface.

    Up first is a ribbon. We want to create a user interface that feels familiar to a user of the application. A great way to achieve this, is using a ribbon known from Office 2007. Currently, Silverlight does not contain a ribbon out-of-the-box yet, but there are some custom-built ones available. For the sake of simplicity, I created a usercontrol containing the ribbon instantiation. This keeps my Page.xaml code cleaner. Codesnippet 5 contains the code for the ribbon and codesnippet 6 contains the usercontrol that we’ll put on the page.

       1: <rbn:Ribbon.QuickLaunchButtons>
       2:                 <rbn:RibbonButton SmallImageSource="Images/Save.png" />
       3:                 <rbn:RibbonButton SmallImageSource="Images/Undo.png"  />
       4:                 <rbn:RibbonButton SmallImageSource="Images/Repeat.png" />
       5:             </rbn:Ribbon.QuickLaunchButtons>
       6:  
       7:             <!-- Tabs -->
       8:  
       9:             <!-- Home -->
      10:             <rbn:RibbonTab Title="Home">
      11:                 <rbn:RibbonTabGroup Title="Actions">
      12:                     <rbn:RibbonButton Text="New data" LargeImageSource="Images/addxml.png" />
      13:                     <rbn:RibbonButton Text="Change data" LargeImageSource="Images/addxml.png" ButtonClick="RibbonButton_ButtonClick" />
      14:                     <rbn:RibbonButton Text="Images" LargeImageSource="Images/addimages.png" />
      15:                 </rbn:RibbonTabGroup>
      16:                 
      17:                 <rbn:RibbonTabGroup Title="Reporting">
      18:                     <rbn:RibbonButton Text="New report" LargeImageSource="Images/addreport.png" />
      19:                     <rbn:RibbonButton Text="View reports" LargeImageSource="Images/addreport.png" />
      20:                 </rbn:RibbonTabGroup>
      21:             </rbn:RibbonTab>
      22:  
      23:             <!-- Help -->
      24:             <rbn:RibbonTab Title="Help">
      25:                 <rbn:RibbonTabGroup Title="Help">
      26:                     <rbn:RibbonButton Text="About" LargeImageSource="Images/about.png" />
      27:                     <rbn:RibbonButton Text="Help" LargeImageSource="Images/help2.png" />
      28:                 </rbn:RibbonTabGroup>
      29:  
      30:             </rbn:RibbonTab>
      31:  
      32:         </rbn:Ribbon>

    Codesnippet 5

       1: <!-- Ribbon -->
       2:             <usercontrols:RibbonControl Grid.Row="0" Grid.Column="0" 
       3:                           x:Name="mainRibbon" VerticalAlignment="Top"></usercontrols:RibbonControl>

    Codesnippet 6

    silverlightonthebike4

    Next, we’ll add a Telerik Coverflow control that will enable us to flip through the images. Telerik as well as Infragistics (and many other vendors) have been busy creating controls suites, giving you many more controls to work with. Codesnippet 7 shows the code for this control.

       1: <telerikNavigation:RadCoverFlow x:Name="coverFlow" CameraY="-80" ItemMaxHeight="100" 
       2:                                             SelectedIndex="5"  VerticalAlignment="Top" CenterOffsetY="15">
       3:                                     <Image Source="Pictures/1.jpg" />
       4:                                     <Image Source="Pictures/2.jpg" />
       5:                                     <Image Source="Pictures/3.jpg" />
       6:                                     <Image Source="Pictures/4.jpg" />
       7:                                     <Image Source="Pictures/5.jpg" />
       8:                                 </telerikNavigation:RadCoverFlow>

    silverlightonthebike5

    One of the main goals of the application is of course the display of the map that will also display the route that Hans did on his bike. A perfect candidate for this is Virtual Earth. On Codeplex, a project called DeepEarth, allows us to display Virtual Earth maps inside a Silverlight application. It also includes all the necessary stuff to show paths, icons etc and allows for easy zooming and panning. We’ll use this control to display the route.

    Of course, we need to convert our data for the map to use. This is very simple code shown in codesnippet 8. What we’re doing here is simply converting our generic list of Trackpoints to a list of points the DeepEarth control can work with. Codesnippet 9 shows the code for displaying the map.

       1: private void AddPolygon()
       2:         {
       3:             ConfigShapeLayer();
       4:             var points = new List<Point> { new Point(0, 0), new Point(20, 0), new Point(20, 20), new Point(0, 20) };
       5:             var polygon = new DeepEarth.Geometry.Polygon { Points = points };
       6:             shapeLayer.Add(polygon);
       7:         }

    Codesnippet 8

       1: <DeepEarth:Map x:Name="map" >
       2:                                     <DeepControls:NavControl>
       3:                                         <DeepControls:MapSourceControl SelectedSource="Hybrid">
       4:                                             <DeepVE:TileLayer MapMode="Aerial" />
       5:                                             <DeepVE:TileLayer MapMode="Hybrid"/>
       6:                                             <DeepVE:TileLayer MapMode="Road" />
       7:                                         </DeepControls:MapSourceControl>
       8:                                     </DeepControls:NavControl>
       9:                                     <DeepControls:CoordControl/>
      10:                                 </DeepEarth:Map>
    Codesnippet 9

    Finally, we need to display the heartbeat, also based on the data in the generic list. We can do this in several ways (for example using the controls from the Silverlight toolkit), but here, I choose to use a listbox. Displaying a heartbeat in a listbox might not sound that normal, as we are used to having the listbox show a list of text items. However, using Silverlight, we can completely restyle the listbox using the data template (Codesnippet 10). The data template allows for complete restyling of the items as well as the listbox’ display area. The item is replaced with an ellipse, absolutely positioned from the top and the display area is replaced with a drawing canvas. (To see the entire code, download the sample). The result is shown below.

    silverlightonthebike6

       1: <DataTemplate>
       2:                                         <Canvas Canvas.Left="10" Canvas.Top="10">
       3:                                             <Ellipse Fill="Blue"
       4:                                          Tag="{Binding}"
       5:                                          Width="10"
       6:                                          Height="10"
       7:                                          Stroke="Black"
       8:                                          StrokeThickness=".5"
       9:                                          MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"
      10:                                          MouseEnter="Ellipse_MouseEnter"
      11:                                          MouseLeave="Ellipse_MouseLeave"
      12:                                          >
      13:                                             </Ellipse>
      14:                                         </Canvas>
      15:                                     </DataTemplate>

    Codesnippet 10

    The final application

    The following image shows the complete application running in the browser. You can download the entire source package by clicking here (Note that I left in all the source code for the other projects like DeepEarth. This way it’s easier for you to experiment with the demo).

    silverlightonthebike7

    (Due to the Virtual Earth webservice being down, the map is not displaying, as can be seen on the screenshot)

    Download the code here.

      Posted on: Saturday, March 21, 2009 1:07:06 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Efficiency | Silverlight     January 25, 2009    

    I just noticed that 2 more webcasts of me have been put online on MSDN Chopsticks.

     


      Posted on: Monday, January 26, 2009 12:19:39 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     ppt | Silverlight | Slide decks     November 8, 2008    

    This week, the Belgian Silverlight Usergroup, Besug (www.besug.be) was officially launched. I gave a talk on Silverlight there which I hope most people enjoyed. If you attended this session and have feedback or questions, don't hesitate to post a comment or send me a mail.

    Here are the slides as promised.

    Below are the sites I used in my showcase at the end of the talk.

    Video.Show: http://www.codeplex.com/videoshow
    Hard Rock: http://memorabilia.hardrock.com/
    Sitemap: http://vertigo.com/deepzoom.aspx
    Cloud: http://www.mojaveexperiment.com/
    Inkubooks: http://inkubook.com/silverlightbooks/
    Renault Laguna: http://www.laguna-coupe.com/
    Line Raider Game: http://linerider.com/play-line-rider-online
    Bird Hunt Game: http://designwithsilverlight.com/csharp/birdhunt/default.html

    And by request, here's the THX "Dramatic Lemur".

      Posted on: Sunday, November 09, 2008 12:45:19 AM (Romance Standard Time, UTC+01:00)   |   Comments [1]
             
    Gill Cleeren     Chopsticks | Silverlight | Webcasts | Efficiency     November 4, 2008    

    The first one on styling Silverlight controls:

    The second one on creating custom Silverlight controls:

    Part 3 is not yet ready...

    I hope you enjoy them!

      Posted on: Tuesday, November 04, 2008 12:20:36 PM (Romance Standard Time, UTC+01:00)   |   Comments [2]
             
    Gill Cleeren     .net 3.5 | PDC | Silverlight     October 17, 2008    

    While the title of this blogpost sounds like the theme song of a British film of a few years back, it's certainly not the most unimportant post of them all...

    Microsoft is really gearing up these last days before PDC 08, which will, as you now MUST know, be taking place in Los Angeles next week. Read Snowball.be from October 25th for my personal coverage from the event!

    Now, on to the releases...

    • Silverlight: Silverlight 2 was released to web on Tuesday of this week. Here's everything you need to get up and running.
    • ASP.NET MVC Beta
      While I haven't spend much time with the MVC framework (one can't do it all, can he...), the framework is moving along fine and moved officially to beta status.
      You can find more information here. Just like always, TheGu has posted all you need to build your first app with the MVC framework.
    • Microsoft Web Application Installer
      Developed to get you up and running with the most free web platforms in no time, the Microsoft Web Application Installer allows you to set up these applications with just a few clicks. Not only ASP.NET apps, no sir! It includes Drupal, PHPBB and Wordpress in addition to .NET apps like DotNetNuke.

      Using the Web Application Installer, you don't have to configure IIS, SQL Server and all the rest.
      Get the beta here.

    This should get you through the weekend!

      Posted on: Saturday, October 18, 2008 1:32:21 AM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
             
    Gill Cleeren     Silverlight     October 13, 2008    

    After being in beta for little more than 6 months, Microsoft released Silverlight 2 to RTM (Release To Manufacturing) today.

    To be clear, today, Monday October 13th, was the official announcement (you can listen to the teleconference here). Tomorrow on Tuesday, the actual bits will be downloadable from www.microsoft.com/silverlight.

    Some of the highlights of the conference, in case you don't have the time to listen for more than 1 hour... ;-):

    • Bits released tomorrow, including the tools for VS 2008 and Expression. Also the Express Edition will support it, which is a good thing for getting more developers on the platform: they don't even need the full version of Visual Studio.
    • Also, Eclipse will be supported as a programming environment.
    • Clients will be auto-updated, so don't expect issues there. Keep in mind that your Silverlight 2 Beta 2 apps will need an upgrade!
    • An open-source control pack will be released by the end of this month on www.codeplex.com. Initially, it will contain 11 controls, the goal is to achieve 50.

    Some other good news is that the adoption rate is really going up: over 25% and in some countries over 50% of PCs have the Silverlight plug-in installed. This should provide an extra boost in convincing that customer that a lot of his visitors already have it installed. (Keep in mind that installing Silverlight only takes about 30 seconds, the download is less than 5mb).

    On questions in the conference, some interesting answers can be found... At the moment, there is no offline support... YET. Chrome will also be supported, and Silverlight for Mobile is currently in private testing.

     

      Posted on: Monday, October 13, 2008 10:23:48 PM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
             
    Gill Cleeren     Silverlight     October 1, 2008    

    Instead of inviting you to the launch event of a usergroup, I'm inviting you to the simultaneous launch of 2 new Belgian user groups: XNA-Bug and the http://www.besug.be/.

    I'm proud to be the speaker for the launch of this event for the Silverlight track. Thanks guys!

    If you want to register, head over to any of the 2 sites mentioned above. The event is free of charge but registration is required.

      Posted on: Thursday, October 02, 2008 1:18:23 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     September 22, 2008    

    The guys over at Telerik have been busy building a great looking - and real world - Silverlight application using their controls suite for Silverlight: the JobBoard application.

    This application shows a Silverlight LOB application. It offers a really rich user experience to the client (notice the speed when searching/filtering jobs).

    Currently, Telerik is offering a rather large set of controls that work on Silverlight 2 Beta 2. You can see them here.

      Posted on: Tuesday, September 23, 2008 12:09:31 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight | Visual Studio.net     August 12, 2008    

    Since the installation of Silverlight 2 Beta 2, I had been experiencing crashes of Visual Studio 2008. The crash always occured when shutting down Visual Studio, but only if I was working on a Silverlight application.

    I figured it had something to do with the Silverlight 2 Beta 2 Tools for Visual Studio, but I had my hopes on VS 2008 SP1 to get rid of all the errors.

    Sadly enough, the error wasn't gone after the install of SP1 and reinstall of the (updated) Silverlight Tools.

    The only thing left was trying to find help, based on the signature of the error:
    EventType : clr20r3    
    P1 : devenv.exe    
    P2 : 9.0.30428.1    
    P3 : 4815597f
    P4 : microsoft.visualstudio.silverlight

    Luckily, the error was the subject of a thread on the Silverlight forums, and some bright reader found what the solution for the error is:
    1. Uninstall the tools (once again in my case...)
    2. Go to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE and search for a DLL called Microsoft.VisualStudio.ServicesProxy.dll. Delete (or better move to a temporary location) this file.
    3. Reinstall the tools.

    If everything went well, the size of the tools in "Control Panel -> Programs and features" should now display 1.17MB instead of 1.14MB.

    Now I can go back to doing Silverlight demo's, knowing that I will not get a crash of my IDE every time :)

      Posted on: Tuesday, August 12, 2008 10:24:55 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     .net 3.5 | Silverlight | Visual Studio.net     August 11, 2008    

    Together with the release of Visual Studio 2008 SP1, Microsoft also released an update of the Silverlight tools. The previous version is not supported anymore.

    The new version can be downloaded here.

    From the Microsoft.com page:
    This package is an add-on to provide tooling for Microsoft Silverlight 2 Beta 2. It can be installed either on top of Visual Studio 2008 RTM or Visual Studio 2008 SP1, and it provides a Silverlight project system for developing Silverlight applications using C# or Visual Basic.

      Posted on: Monday, August 11, 2008 8:11:55 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     .net | Silverlight     June 3, 2008    

    Just a few hours ago, Silverlight 2 Beta 2 was announced at TechEd US. The new version will be available later this week.

    Along with this announcement, the following was also announced:

    Internet Explorer 8 beta 2 will be available this August in 20 languages worldwide. Internet Explorer 8 is the next version of Microsoft’s popular browser, and in beta 1 it delivers significantly improved standards support and developer platform investments with enhanced user experiences. Beta 1 for Internet Explorer 8 is currently available and is focused on Web developers and designers to help them deliver Web experiences that go beyond the page for consumers.
     
    • Availability this week of Silverlight 2 beta 2, the latest version of Microsoft’s cross-browser, cross-platform and cross-device plug-in for delivering the next generation of .NET-based media experiences and rich interactive applications for the Web. Now available with a commercial Go Live license, Silverlight 2 beta 2 will be used to power the unprecedented online experience NBC Universal is creating for the 2008 Beijing Olympics. To help developers take full advantage of Silverlight, Microsoft also released Expression Blend 2.5 June 2008 Preview and Microsoft Silverlight Tools beta 2 for Visual Studio 2008.
     
    • An alliance with IBM that will further simplify application development for enterprise teams working in heterogeneous environments. IBM and Microsoft have agreed to work together to integrate IBM DB2 database access with Visual Studio Team System 2008 Database Edition.
     
    • Multiple partner wins and the latest community technology preview (CTP) of the Microsoft Sync Framework, a comprehensive synchronization platform that enables collaboration and offline scenarios for applications, services and devices. New partners include Fujitsu Siemens Computers, Ontela Inc. and SmugMug Inc. Microsoft Sync Framework will be released in the third quarter of 2008 with full support for the FeedSync open protocol format on devices. A CTP for Windows Mobile support will also be available in the third quarter 2008.
     
    • The first CTP of the Microsoft project code-named “Velocity,” a distributed, in-memory application cache platform that makes it easier to develop scalable, high-performance applications needing frequent access to disparate data sources. Large clusters of machines can be seamlessly integrated into a single cache, providing high availability to data.
     
    • Ongoing momentum for Microsoft code-name “Oslo.” Microsoft reiterated its commitment to model-driven development and focus on helping developers realize the full potential of declarative programming, inspiring collaboration across organizational roles and enabling developers and IT pros to more easily deploy, manage and evolve applications. Microsoft will bolster its investments in a unified modeling platform code-named “Oslo,” which will be used by future versions of Visual Studio, Microsoft System Center, BizTalk Server and Microsoft SQL Server. “Oslo” will include visual modeling and composition tools, a foundational repository built on SQL Server 2008 for managing application metadata, and a new, declarative modeling language to enable interoperability of models between tools and domain-specific modeling notations.
     
    • A new version of Visual Studio 2008 extensions for Windows SharePoint Services 3.0 v1.2, which will allow developers to use Visual Studio 2008 to extend the value of Windows SharePoint Services and Microsoft Office SharePoint Server by providing a simplified development environment.
     

      Posted on: Tuesday, June 03, 2008 11:53:49 PM (Romance Daylight Time, UTC+02:00)   |   Comments [2]
             
    Gill Cleeren     .net 3.5 | ASP.net | ASP.net AJAX | LINQ | Silverlight     May 15, 2008    

    Yesterday, I gave my talk on ASP.NET 3.5 - AJAX - LINQ - Silverlight for Visug. Here is the slide deck of that talk:

    http://www.codeflakes.net/blog/file.axd?file=ASP_NET35_AJAX_LINQ_Silverlight.pptx

      Posted on: Thursday, May 15, 2008 9:41:43 AM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
             
    Gill Cleeren     Silverlight     April 28, 2008    

    The past 3 days, I've been working on my article on using Silverlight with all kinds of data and services. This is in fact like a transcript of the session I did at Mix Essentials in Belgium last week, but now in tutorial-format.

    First, I take you through building services that are ready to be consumed by Silverlight clients using WCF. Then, we take a look at 3 types of services your Silverlight application can connect with: self-describing (using WSDL, meta-data driven), non-self-describing services (REST APIs like Flickr...) and finally RSS.

    I hope this article really helps you in finding your way in Silverlight.

    I posted the article on my "article-blog", www.CodeFlakes.net. The link is the following: http://www.codeflakes.net/blog/post/Silverlight2c-Data-and-Services-The-complete-story.aspx

      Posted on: Monday, April 28, 2008 11:53:03 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Mix 08 | ppt | Silverlight     April 24, 2008    

    Today I delivered a session on Mix Essentials in Belgium (Louvain-La-Neuve). The talk was about connecting Silverlight with services and data. Everything went great and every single demo worked as expected.

    This morning however, I do was a little bit scared when I was trying out my demo's. I had one demo with the Flickr REST API and when testing it this morning, it didn't work anymore. Turned out that the most "easy" solution actually solved it: Flickr.com was down for about 10 minutes...

    As promised, below you can download the slides and demo's. If you have any questions, please contact me.

    Slidedeck: Working with Data and Web Services in Microsoft Silverlight 2 - Gill Cleeren.pptx
    Demo's: Demos.zip

    I hope you enjoyed the session and if you have any comments about the session, please post them!

    Update: here are my pictures of the event! If you have any, please post!

      Posted on: Thursday, April 24, 2008 10:21:34 PM (Romance Daylight Time, UTC+02:00)   |   Comments [3]
             
    Gill Cleeren     Events | Silverlight     April 2, 2008    

    It looks like I'll be having some very busy months in front of me: the MVP summit is only 10 days away and after that, I'll be doing several talks, including Mix Essentials in Belgium.

    Here's an overview of upcoming events that I'll be talking at:

    • 24th April: Mix Essentials
      Session: Working with Data and Web Services in Microsoft Silverlight 2
      Learn how easy it is to utilize POX, REST, RSS, ATOM, JSON, and SOAP in your Microsoft Silverlight mashup applications. Also learn how to easily access and display data with Silverlight using LINQ and databinding.
      Do note that Steve Ballmer will be at this event!
    • May 14th: Visug - Microsoft Heroes Community Launch (Ordina Lummen)
      Session: ASP.NET 3.5, AJAX and LINQ 
      In this session, you'll see all the new stuff that Microsoft added to ASP.NET 3.5 and ASP.NET AJAX. From the new controls, the new IDE, the transparent integration of LINQ, AJAX powered... you'll learn everything you'll need to know to use the new features to their fullest power.
      In the second part, we'll cover LINQ, the new Language Integrated Query features in C# 3.0.
    • May 20th: Visug - Microsoft Heroes Community Launch (Ordina Schelle)
      Session: ASP.NET 3.5, AJAX and LINQ 
      In this session, you'll see all the new stuff that Microsoft added to ASP.NET 3.5 and ASP.NET AJAX. From the new controls, the new IDE, the transparent integration of LINQ, AJAX powered... you'll learn everything you'll need to know to use the new features to their fullest power.
      In the second part, we'll cover LINQ, the new Language Integrated Query features in C# 3.0.
    • May 23rd: Multi-Mania (Kortrijk)
      Session: Building Rich Internet Applications With Silverlight 2
      Silverlight is a cross-browser and cross-platform plug-in for delivering next generation of .NET based media experiences and rich interactive applications for the Web.
      In this demo-packed session, you’ll see how to build Silverlight 2 applications using Visual Studio 2008, how to create a UI using XAML markup and code and how to access data from a web service. We’ll also take a look at how Silverlight and LINQ work together. Finally, we’ll be looking at “Deep Zoom”, a new technology in Silverlight that offers a better user experience when viewing large images on the web.
    • May 27th: IT Club Syntra West(Kortrijk)
      Session: Silverlight Deep Dive
    • June 26th: CommunityDay 2008 (Keerbergen)
      Session: Silverlight 2 (TBA)
    All but the IT Club events are free to attend, so if you want to expand your knowledge on the above subjects, please feel free to attend my talks. Demo's and slides will be posted here after each of these events.


      Posted on: Wednesday, April 02, 2008 10:49:17 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     March 5, 2008    

    Silverlight is launching with a real bang! Here are some links on video's, labs and tutorials already.

    Video's: http://silverlight.net/Learn/videocat.aspx?cat=2

    Tutorials: http://silverlight.net/learn/tutorials.aspx

    Labs: http://silverlight.net/learn/labs.aspx

      Posted on: Wednesday, March 05, 2008 8:16:56 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     March 5, 2008    
      Posted on: Wednesday, March 05, 2008 7:29:04 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     .net | Silverlight | WPF | Expression | Mix 08     March 4, 2008    

    Wow, what an exciting week this is! In fact, I'm having trouble waiting for all the info that will come our way tomorrow.
    Why tomorrow, you might ask? Well, Mix'08 is starting in Las Vegas in just a few hours. And as expectec, a lot of great info and visions will be shared, mostly during the big opening keynote.

    A little further in this post, I have collected some info I managed to find already. Some of the things we'll see being announced tomorrow will greatly expand the possibilities we as webdevelopers/designers have. In fact, the web is wide open, the oppurtunities coming are way are endless.

    One of, if not THE biggest announcement tomorrow, will of course be Silverlight 2.0 beta. A great toolset will make it much easier to create next-gen UX for the web. Datagrids will be on the rendez-vous, whom are still missed in WPF however. Today, Nokia announced the availability of Silverlight on their (Symbian) smartphones, so it's a guess, but I think we'll see more on a mobile version of Silverlight tomorrow (as I said, it's a guess...)

    I managed to find some info on Expression too... Expression Studio V2 is coming this April appearantly, if we can already believe the rumors. Laurent Bugnion has more info on that on his blog.

    And if you're not in Vegas, do use the possibilites of the web to take a look at the future! The opening keynote will be broadcast live (750kbps, 300kbps, 100kbps) at 9:30am Pacific / 5:30pm GMT. Microsoft also made a promise that all sessions will be downloadable within 24 hours! That means, start your download engines, go get soms sleep today, as you won't be having any time to go to bed once all this info is online!

    Stay tuned for more Mix info on Snowball.be!

      Posted on: Tuesday, March 04, 2008 10:03:50 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     February 8, 2008    

    It's not me who is saying this, but here's an extract from a very interesting view on the future of Silverlight:

    With the introduction of Silverlight, they are bringing over 20 years of experience building visual, interactive business and shrink wrapped applications, to the web.  That is amazingly powerful.  You simply can’t discount this. It's so powerful in fact that speaking with Flex developers recently, they even drooled at the things they could conceivably do with a .net/Flash interactive package.  I mean, have you tried building really rich data driven, interactive, cross domain, scalable applications in Flash/Flex?  It’s horrid, if not next to impossible.

    Is Silverlight a Flash killer?  No.  Is it intended to be?  Nope.  It's much more than that.  Will you still see flash animations on sites? Absolutely.  But, will you see real applications on the web, built in "AJAX"/Flash?  Nope, they will be built using Silverlight.  Dare I say, you might someday see Flash running on top of Silverlight!  Why not?

    The full article can be read here.

      Posted on: Friday, February 08, 2008 10:40:42 PM (Romance Standard Time, UTC+01:00)   |   Comments [1]
             
    Gill Cleeren     .net 3.5 | Chopsticks | Silverlight | Webcasts     February 8, 2008    

    I just got the news that my first 2 Chopsticks video's are online.

    In the first video, I give a general overview of Silverlight 1.0 development, complete with 2 demo's.

    In the second one, I'm explaining all you need to know on the Silverlight downloader object and the CreateFromXaml method.

     

    You can see many more interesting Chopsticks video's here.

      Posted on: Friday, February 08, 2008 9:35:47 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     January 14, 2008    

    If you're new to Silverlight development, here's something that can help you on your way.

    The Silverlight 1.0 Fire Starter is a one-day event providing developers and designers information on the concept behind Silverlight as a technology, what tools are useful in development and the knowledge in order to start building their own applications. The eight sessions listed, are available to watch here and to be downloaded in video and audio formats.

    Yes, you do want to read more! Here you go!

      Posted on: Monday, January 14, 2008 11:36:18 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     January 7, 2008    

    The Olympic Games 2008 haven't started yet, but Silverlight is already a winner way back there in China. I just got this from Soma's blog:

    We have signed an agreement to partner with NBC Universal to build a Silverlight 2.0 based web broadcast of the 2008 Summer Olympic games.  This agreement also sets MSN as the official home of the 2008 Summer Olympics.  

     

    As a part of this, we will provide users with exclusive access to over 3000 hours of live and on-demand video content via Silverlight streaming.  This means that viewers can access every minute of every event.  Additionally, the amount of meta-data attached to each of the streams will be extensive and include links to player bios, medal counts, shortcuts to particular events (i.e. athlete x’s third long-jump attempt), maps of the Olympic facilities, pop-up overlays with real-time event alerts, headlines, video search capabilities, etc.  

     

    It is exciting to see Silverlight be the catalyst to turn “NBCOlympics.com on MSN” into a ground breaking site and video experience that will redefine sports content online and in some small way we can be part of this historic event.

      Posted on: Monday, January 07, 2008 11:19:35 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight | WPF | XAML     January 6, 2008    

    KaXaml has finally hit the 1.0 milestone! Indeed, finally!

    In case you don't know this great little (free) XAML tool, here's what the official website has to say on it:
    Kaxaml is a lightweight XAML editor that gives you a "split view" so you can see both your XAML and your rendered content (kind of like XamlPad but without the gigabyte of SDK).

    There are a lot of new features included in the 1.0 release, including Intellisense support, a new UI and tabsupport. To see an overview of all the new features, go here. One other interesting thing it that it now has basic support for Silverlight too!

    Convinced that this can and will make your XAML life easier? Go here for the free download or visit www.kaxaml.com .

      Posted on: Monday, January 07, 2008 12:02:28 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     December 31, 2007    

    If you've never seen Jeff Prosise in real life, you are missing out on a great speaker that has an outspoken opinion on trends in the industry. Last year, I was able to talk with him one-on-one at DevDays in Ghent on the upcoming release of Silverlight (at that point still WPF/E).

    Today, DotNetRocks.com published an interview with him. Whether you're like me, convinced that Silverlight is key to the future of web development, or you're still sceptic on the whole thing, do listen to the interview, as it provides some great insights in what Silverlight really has to offer.

    Here you can download the interview in full: http://www.dotnetrocks.com/default.aspx?ShowNum=302

     

      Posted on: Monday, December 31, 2007 11:38:01 PM (Romance Standard Time, UTC+01:00)   |   Comments [1]
             
    Gill Cleeren     Silverlight     December 23, 2007    

    The Windows Live Platform team released the Tafiti Search Visualization source code to CodePlex. That means that every dev'er can now read, modify and re-use the code that makes up the nice visualization of Live Search results over at www.tafiti.com.

    If you don't know what Tafiti is, it is a search visualization website which brings a new user experience to researching (searching and storing results). It was originally created by Microsoft to demonstrate Silverlight and the Windows Live Search APIs.

    tafiti screenshots

    If you want to download the code, go here. It's a also great resource for advanced Silverlight development.

     

      Posted on: Sunday, December 23, 2007 9:53:48 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     December 17, 2007    

    One of my favorite control builders (mainly because of their controls being very lightweight), Telerik, has announced their control toolset for Silverlight.
    Included are the following controls:

    • Buttons (Simple, Toggle, Repeat, DropDown)
    • CheckBox & RadioButton
    • RadCombobox
    • RadListBox
    • RadMenu
    • RadProgressBar
    • RadScrollViewer
    • RadSlider
    • RadTabStrip
    • RadTextBox
    • RadTreeView
    • RadUpload

    RadTreeView

    When will all this be available? A first beta is expected with the release of the Silverlight 2.0 beta in March and the final release will follow the Silverlight final release later in 2008.

      Posted on: Monday, December 17, 2007 11:24:07 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Mix 07 | Programming | Silverlight | Visug     December 16, 2007    

    I'm proud to annouce the Belgian availability of the first European Silverlight Challenge, organised by Ineta Europe. In Belgium, Visug, the Belgian Visual Studio User Group, is the usergroup that organises this challenge.

    Header_ESC

    Probably, you haven't heard of this competition yet. Well then, let me explain what you have to do in order to participate, and, maybe more importantly, what great prices are to be won!

    The goal is to get more people developing Silverlight applications. As a participant, you can create whatever application you wish in Silverlight (may be in combination with another technology, for example ASP.NET/ASP.NET AJAX). You can upload your creation to our Belgian competition website, http://belgium.silverlightchallenge.eu. Do not upload it to the general website (www.silverlightchallenge.eu). The creations that reach us before January 31st 2008, will take part in the competition. A jury will then decide on 4 winners between the Belgian creations. The best creation will be entered in the European contest afterwards, where a jury will select the best participation over all countries.

     

    Prizes_small

    Ready to start creating your Silverlight application? Maybe you'll get even more creative when you hear what great prizes you can win!

    For the Belgian competition, these are the prizes:

  • 1st Prize :
    • To be confirmed: MSDN subscription
    • IdeaBlade's DevForce Professional License
    • JetBrains's ReSharper + DotTrace bundle,
    • Wrike - 2 year 5-user subscription
    • Telerik RadControls for ASP.NET Developer Subscription and Source Code License.
  • 2nd Prize :
    • Infragistic's NetAdvantage for .NET
    • Jet Brains's ReSharper
    • Wrike - 2 Year 1 user subscription
    • O'reilly Book (to choose from this five books: Learning WCF Programming WPF Learning ASP.NET 2.0 Ajax Programming ASP.NET Ajax Head First C# - Please consider that this last book has still not been published and might not be available)
  • 3rd Prize :
    • Component One's DemoWorks licenses
    • Wrike - 2 Year 1 user subscription
  • 4th Prize (Students) :
    • 25 Silverlight Unleashed
    • Wrike - 2 Year 1 user subscription

     

    And finallay, the European prizes:

  • 1st. Prize :
    • MIX '08 ticket & travel,
    • 1 DevForce Enterprise License (without BOS)
    • 1 Telerik's RadControls for ASP.NET + WinForms + Reporting Developer Subscription and Source Code Licenses
    • 1 Component One's Enterprise Studio Subscription
    • Wrike  2 year 15 user Subscription
  • 2nd. Prize :
    • MIX '08 ticket & travel
    • 1 Telerik's RadControls for ASP.NET + WinForms + Reporting Developer Subscription and Source Code Licenses
    • 1 Component One's Enterprise Studio Subscription
    • 1 Red-Gate's NET professional bundle (ANTS Profiler Pro)
  • 3rd. Prize :
    • MIX '08 : ticket & travel FC
    • 1 Telerik's RadControls for ASP.NET + WinForms + Reporting Developer Subscription and Source Code Licenses
    • 1 Component One's Enterprise Studio Subscription
  • 4th. Prize (students) :
    • 1 Telerik's RadControls for ASP.NET + WinForms + Reporting Developer Subscription and Source Code Licenses

     

    Did I just hear your brains thinkering on what you should create? I think I did, dear reader! Whenever your creation is ready for publication, upload it to http://belgium.silverlightchallenge.eu . If you are in need for further assistance, you can contact me through the contact form on the challenge website or simply use the comments here.

     

    Here are some banners you can use to put on your own blog to promote our competition. Start spreading the word!

    ESC_Banner_468_60 

    ESC_Banner_120_240

    ESC_Banner_120_120 

  •   Posted on: Sunday, December 16, 2007 5:39:34 PM (Romance Standard Time, UTC+01:00)   |   Comments [1]
             
    Gill Cleeren     .net 3.5 | ASP.net | Silverlight | ASP.NET MVC     December 10, 2007    

    Just after the ADO.net Entity Framework went into Beta 3, Scott Guthrie's team released the first CTP ASP.NET 3.5 extensions, which contain the MVC Framework (Model View Controller), ASP.NET AJAX Improvements, ASP.NET Silverlight Support, ADO.NET Data Services and ASP.NET Dynamic Data Support.

    I have just finished installing it, since I'm really looking forward to the MVC framework. However, I'm not really sure as what to expect, since it really brings a new way of developing ASP.NET applications into play.

    The installation gave me this strange but very honest error...

    But, it ended up installing everything correctly, the extensions are showing up inside of the Project Template window.

    I'm hoping to find some time to start exploring the new Silverlight controls...

    All of this candy can be downloaded here.
    Video's on using the MVC and other stuff included in this release can be found here.

      Posted on: Monday, December 10, 2007 5:15:07 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Microsoft | Silverlight     December 6, 2007    

    TechNet Belgium have just lauched Chopsticks, the new platform for on-demand webcasts. With this new platform, you'll be sitting in the front row to view all kinds of (deep) technical content on every aspect of the IT Pro world.

    The player, created entirely in Silverlight, allows for embedding in your own blog, like the sample I have included below, which is the Tech-Ed 2007 Opening Keynote .

    I'm proud to say I helped a bit during the development, though most of the credit should go to the Microsoft team and especially Wim Verhaeghen! Congrats to the entire team!

    If you want to view the other videos, here's the link: http://www.microsoft.com/belux/technet/nl/chopsticks . Much more video's are in the pipeline, so you better check back regularly!

      Posted on: Thursday, December 06, 2007 11:22:06 PM (Romance Standard Time, UTC+01:00)   |   Comments [1]
             
    Gill Cleeren     ASP.net | Silverlight | Visug     November 25, 2007    

    If you attended my small talk on ASP.net futures (Silverlight and MediaPlayer controls) and you want to see the slides or the demo's again, click here.

    If you want to see the other slidedeck, I have just posted them on the Visug website on this page.

    Thanks for attending, it was a fun event!

      Posted on: Sunday, November 25, 2007 5:31:36 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     .net | .net 3.5 | ASP.net | C# | Silverlight | Visual Studio.net     November 20, 2007    

    Finally, we can present the RTM version of the Visual Studio 2008 RTM Training Kit.
    This kit is a real goldmine, containing presentations, Hands-On-Labs, demo's... on all topics related to Visual Studio 2008.
    Now you only have to find about 5 days to complete all that's in here, and you're set!


    All the info is below:
    The Visual Studio 2008 Training Kit has been updated for the RTM and has been released on the Microsoft.com Download Center for anyone to download and use.

    The Visual Studio 2008 Training Kit contains a full 5-days of technical content including 20 hands-on labs, 28 presentations, and 20 scripted demos.   The technologies covered in the kit include:  LINQ, C# 3.0, VB 9, WCF, WF, WPF, Windows CardSpace, Silverlight, ASP.NET Ajax, .NET Compact Framework 3.5, VSTO 3.0, Visual Studio Team System, and Team Foundation Server. 

    Originally developed for early adoption work with ISVs, it is now available to all. 

    You can download the entire training kit from the download center here:  http://go.microsoft.com/?linkid=7602397.  The kit is just over 120MB compressed.   After downloading the kit, simply run the installation program to extract the contents to your local machine.  Once the installation process is complete, you will see an HTML page that allows you to navigate through the contents of the kit.  

      Posted on: Tuesday, November 20, 2007 10:51:38 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     November 20, 2007    

    Already downloaded VS 2008 RTM? Great!
    Doing some Silverlight 1.1 development? Great too!

    However, the combination of both is not yet possible. At this moment, you can't use the Silverlight 1.1 Tools Alpha for Visual Studio yet with the RTM release. Here's what Scott Guthrie says on this subject:

    Two popular add-ins to Visual Studio are not yet available to download for the final VS 2008 release.  These are the Silverlight 1.1 Tools Alpha for Visual Studio and the Web Deployment Project add-in for Visual Studio.  Our hope is to post updates to both of them to work with the final VS 2008 release in the next two weeks.  If you are doing Silverlight 1.1 development using VS 2008 Beta2 you'll want to stick with with VS 2008 Beta2 until this updated Silverlight Tools Add-In is available. 

    So, the message is clear, don't go uninstalling VS 2008 beta 2 just yet, as you won't be able to work on Silverlight projects anymore.

      Posted on: Tuesday, November 20, 2007 11:01:02 AM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     November 14, 2007    

    One of the first control builders to announce support for Silverlight, was Component One. With their "Sapphire" suite, they were busy creating great looking controls for Silverlight.



    As of today, the site is updated, the toolset renamed to Studio Enterprise Silverlight Toolset and you can sign up for the alpha release here. Some demo's are available there too!

    Other component designers have some early demo's available too. Go here for the preview of Telerik. Or if you are more an Infragistics minded person, you can sign up here for their preview, which is due very shortly.

    Update: I posted a small article on some troubles I had with Sapphire right from the start here. If the controls remain invisible, be sure to check it out!

      Posted on: Wednesday, November 14, 2007 11:37:51 PM (Romance Standard Time, UTC+01:00)   |   Comments [0]
             
    Gill Cleeren     .net | .net 3.5 | ASP.net | Links | Programming | Silverlight     November 12, 2007    

    Here are some links you might find useful:
    -LINQ cookbook: series of solutions to specific scenarios, that the team comes across when writing code and using queries
    -Nice intro to ASP.NET MVC framework
    -Looking for a replacement for FreeTextBox? Maybe this newly created rich text box for ASP.NET is the solution: http://www.codeplex.com/rte



    -Automatic Properties and Initializers in C# 3.0: a nice introduction on these new features in C# 3.0.

    I hope you can find some use of these links. Feel free to post interesting links in the comments!
      Posted on: Monday, November 12, 2007 9:16:21 PM (Romance Standard Time, UTC+01:00)   |   Comments [2]
             
    Gill Cleeren     .net | Silverlight | WPF     November 12, 2007    

    Since the dawn of WPF (Windows Presentation Foundation), it became easy for developers to create applications that were nearly impossible to create without it. Creating animations, transformations, gradients is as easy as 1-2-3. In the end, the user who has to work with the application will benefit from this. The User Interface is what you are looking at every day, so don't you want it to look at least a little nicer than the old-school grey?

    Sadly enough, I still hear people complain that UI is not important, which is ignorant in my opinion(Ignorance is bliss, they say, however in this case, I beg to differ). If you have the nicest architecture imaginable, if your application is developed with the latest best practices or if you used the newest ways of service communication, it all falls apart when your application looks like it was developed in the 90's. The end user will not see this.
    Take your average customer and present him an ugly and nicely architectured program, and another one, only this time with a really cool looking UI, but not developed as it should.
    Which one will he choose? I would bet my money on the latter one.

    Maybe it's not obvious at first sight, but I'm sure that users really look for nicer looking apps. Computers are capable of displaying nicer graphics, well then, use this possibility.
    I rest assured that WPF and Silverlight really are the platforms to develop next-gen applications.

    In a question to Dino Esposito on DevConn07 on the fact if Silverlight and WPF will replace Winforms and ASP.net, he says the following:

    I firmly believe that the two worlds—Web and Windows—will remain neatly separated for most of the foreseeable future.  At the same time, though, the advent of WPF and Silverlight generates many more possibilities of interaction between Web and Windows that were just impossible or impractical before.  Once the next Silverlight is available you can develop for the Web with much of the same ease you experience today for the desktop. You could even get to the point of using the same WPF document to power the Web and Windows front-end of a multi-tier system. Well, not for free, but is definitely a scenario that the use of proper design patterns (i.e., the Model-View-Presenter pattern) may enable. At that point, I believe that you just have two options--deluxe experience with a 100% Silverlight solution or normally rich Web experience with a combination of AJAX and Silverlight in the same ASP.NET page. With Silverlight used in this case as a rendering engine for special data.

    To be more direct with the question: For Silverlight and WPF to dethrone ASP.NET and AJAX all developers on all platforms must agree to use it. Technologically speaking, nothing prevents this from happening. In practice, though, I wouldn’t bet on it. But I see a lot of interaction taking place between Silverlight and ASP.NET AJAX applications.

    I do think the same. I'm not suggesting WPF and Silverlight will replace ASP.net entirely, but I do believe that in the NEAR future, when the demand for RIA's (rich interactive applications) will rise, those companies that are ready for this, will profit from this.

    Do note that I'm not promoting bad architecture in my opinion here, quite the opposite in fact. BUT I reckon that it should be in combination with a well designed user interface, using the newest applicable technologies. I'm trying to convince people to start thinking this way... Let's hope for the best.

      Posted on: Monday, November 12, 2007 8:41:55 PM (Romance Standard Time, UTC+01:00)   |   Comments [1]
             
    Gill Cleeren     Silverlight     November 2, 2007    

    Pfew, that was a lot of work! Maybe you have attended my talk on Silverlight for MSDN (MSDN evening) in Mechelen, Belgium...
    We had over 150 registrations, which was a great amount. It really shows that Silverlight is a hot topic, and in the coming months, it will become even hotter.

    After I return from TechEd, I'll be writing articles on Silverlight again, now that the presentations are finished, I have some extra free time to do so!

     

    Again, for those that attended, I hope you enjoyed the session, and thank you for being there!

      Posted on: Friday, November 02, 2007 11:07:14 AM (Romance Standard Time, UTC+01:00)   |   Comments [2]
             
    Gill Cleeren     Silverlight     October 8, 2007    

    After the 2 succesfull sessions for Visug, MSDN Belux is organizing an MSDN evening on Silverlight in Mechelen. The session will take place at Utopolis on October 31st (yes, indeed on Halloween, hence the orange ;-) ).

    In this session, Gill Cleeren will guide you through all the aspects that you need to know to get started developing your own Silverlight applications. You'll get an overview of what the new platform is capable of: we'll be browsing through the rich media capabilities, we'll be making a stop at the programming model for both Silverlight 1.0 and 1.1 and we'll arrive the rich tool support for developing Silverlight applications.

    So, instead of 'trick or treat'ing this year, join us at Utopolis in Mechelen for this MSDN evening. It's free, but registration is required, and can be done here.

    I hope you'll join me!

    Important note: the content is completely different from the Visug sessions, this is NOT a redelivery!

      Posted on: Monday, October 08, 2007 9:55:04 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight | WPF | XAML | Blend     September 24, 2007    

    Yesterday, another CTP of Blend 2, THE tool for create Silverlight and Windows Presentation Foundation applications, was released. This time, it's the September Preview.
    Here's a list of what was added/changed:

    • VS2008 beta 2 full support
    • Creation of Controls from existing objects - reuse them all.
    • Some enhancements with Split View - now you can see Design and Code both as well as you can do it in Visual Studio
    • Storyboard picker - the old Storyboard panel has been thrown and replaced with brand new storyboard picker. Now you can duplicate, reverse or delete existing storyboard or easy modify its properties.
    • Aside with new storyboard picker, now you have properties panel both for all sotryboard or single frame.
    • New functionality - 3D Vertex animation
    • Long awaited Breadcrumb bar
    • Subsetting and embedding fonts within your application (EULA awarded)
    • New build options - how you can create custom builds for better integration with Visual Studio
    • New abilities of object manipulation - uniformly resize, scale, rotate multiple objects, resizing handlers at artboard. Easy object duplication by dragging with Ctrl-P pressed.

    You can download a free copy here.

      Posted on: Monday, September 24, 2007 11:37:54 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     September 23, 2007    

    Last week, I gave the first delivery of my Silverlight presentation for Visug (Visual Studio Usergroup Belgium). It was a success: not one demo went wrong, and we had over 60 guests. I'll be doing a next session this week, again for Visug. A third redelivery will be done later.

    For those interested in my slides and demo's, I have just finished uploading them.

    If you have visited my presentation, thanks for being there.
    Feel free to re-use this presentation or the demo's. If you like them, or if you have any questions, please drop me a mail.

      Posted on: Sunday, September 23, 2007 2:57:52 PM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
             
    Gill Cleeren     Personal | Silverlight     September 7, 2007    

    As of today, the Visug Silverlight sessions are on www.msdn.be. Please remember there's a second session on September 26th in Leuven (Haasrode) for those that are not able to come to the first session.

    Hope to see you then!

      Posted on: Friday, September 07, 2007 9:36:06 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     September 5, 2007    

    Yep, it's here! Version 1.0 of Silverlight is final, and can be downloaded from www.silverlight.net .

    If you have 1.1 refresh (August) installed, I found out you might get an error when trying to install 1.0 final: the errorcode is 4001/ DownloadError. The reason you receive this error, is because of a version problem: I had version 806 installed (the 1.1 refresh thus), and the 1.0 appearantly has a lower version number.

    The solution: install September refresh of 1.1, which will upgrade your version to 816.

    Some more info on Silverlight, for those who don't know it yet (from Scott):

    Silverlight 1.0 is focused on enabling rich media scenarios in a browser. Some of its features include:

    • Built-in codec support for playing VC-1 and WMV video, and MP3 and WMA audio within a browser.  The VC-1 codec is a big step forward for incorporating media within a web experience - since it supports very efficiently playing high-quality, high definition video in the browser.  It is a standards-based media format that is implemented in all HD-DVD and Blueray DVD players, and is supported by hundreds of millions of mobile devices, XBOX 360s, PlayStation 3s, and Windows Media Centers (enabling you to encode content once and run it on all of these devices + Silverlight unmodified).  It enables you to use a huge library of existing video content and provides access to the broad ecosystem of existing Windows Media tools, components, vendors and hardware. 
    • Silverlight supports the ability to progressively download and play media content from any web-server.  You can point Silverlight at any URL containing video/audio media content, and it will download it and enable you to play it within the browser.  No special server software is required, and Silverlight can work with any web-server (including Apache on Linux).  We'll also be releasing an IIS 7.0 media pack that enables rich bandwidth throttling features that you can enable on your web-server for free.
    • Silverlight also optionally supports built-in media streaming.  This enables you to use a streaming server like Windows Media Server on the backend to efficiently stream video/audio (note: Windows Media Server is a free product that runs on Windows Server).  Streaming brings some significant benefits in that: 1) it can improve the end-user's experience when they seek around in a large video stream, and 2) it can dramatically lower your bandwidth costs. 

    • Silverlight enables you to create rich UI and animations, and blend vector graphics with HTML to create compelling content experiences.  It supports a Javascript programming model to develop these.  One benefit of this is that it makes it really easy to integrate these experiences within AJAX web-pages (since you can write Javascript code to update both the HTML and XAML elements together). 

    • Silverlight makes it easy to build rich video player interactive experiences.  You can blend together its media capabilities with the vector graphic support to create any type of media playing experience you want.  Silverlight includes the ability to "go full screen" to create a completely immersive experience, as well as to overlay menus/content/controls/text directly on top of running video content (allowing you to enable DVD like experiences).  Silverlight also provides the ability to resize running video on the fly without requiring the video stream to be stopped or restarted.

      Posted on: Wednesday, September 05, 2007 11:54:07 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     .net | Silverlight | Visug | WPF | XAML     August 10, 2007    

    I'll be doing a session on Silverlight next month, on September 20th for Visug, the Belgian Visual Studio User Group. In this session, I'll give an overview of XAML too, so that if you've got no knowledge, you'll still be able to follow the entire session. This event will take place in the Ordina (my company) buildings in Schelle.

    I will announce the complete overview in a few days, as I'll be working on my session in the coming week (I have a week off, but I'll be working anyhow ;-) ).

    If you want to register for this free training, please go to www.visug.be and click on the event! So, what are you waiting for?!?!

      Posted on: Friday, August 10, 2007 11:12:59 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     August 10, 2007    

    Starting today, you can store your RIA program data in our cloud storage servers.  The service is still experimental, and limited to 100MB storage, but this is huge.  You can start getting your feet wet today, develop some cool applications, and get prepared for the future of rich Internet applications.

    This scenario is potentially game-changing.  With a solution like this, you'll be able to deploy rich apps that maintain state, without having to maintain a server cluster.  We already have thousands of developers using Silverlight Streaming services to deploy rich client code (which can include .NET code, Python, etc.).  Now developers can tie to a powerful back-end data store which supports the entity model using XML or JSON.  All without configuring a single web server or database server.

    To get started, read the introductory materials or watch the session from MIX07, and create your account.  You can build your data model entirely online.  You can get support and inspiration on the forums.

    (Via activeWin)

      Posted on: Friday, August 10, 2007 9:42:41 PM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
             
    Gill Cleeren     Silverlight     August 10, 2007    

    At least, the first major project using the technology is: the Web site for Major League Baseball using version 1.0 of the browser for interactive video content.

    MLB.com is in the early stages of its use of Silverlight to enhance the site with multimedia content, said Matthew Gould, a spokesman for the site. Eventually, MLB.com plans to relaunch its MLB.TV live game media player, which streams baseball games on the Internet, with the technology. A beta of the revamped player is expected to be live in about a month, he said.

    More here.

      Posted on: Friday, August 10, 2007 9:37:14 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     August 10, 2007    

    Remember when Microsoft announced Silverlight at Mix07? It would be cross platform. Up until now, critics have been blaming Microsoft that this is not true, saying that Silverlight was not supported on Linux.

    Well, appearantly, they are proven wrong, since some of Microsoft’s top developers have provided technical guidance for a Linux implementation of Silverlight.

    More on the evolution on this story here.

      Posted on: Friday, August 10, 2007 9:27:09 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     August 2, 2007    

    As we close down on the release, MS is actually pushing out an update to the Silverlight RC build in the next couple of hours. The update is Sunday night's drop - build 20730 (the last release was 20724), and will dubbed RC2.

    This is one of a few critical updates that will be pushed down over the next couple of weeks to test the update mechanism.

    More here.

      Posted on: Thursday, August 02, 2007 8:51:36 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     July 28, 2007    

    Following the beta 2 release of Visual Studio 2008, Silverlight was also upgraded, both 1.0 and 1.1!
    Since the release at Mix 07, over 2000 (!) bugs were fixed and 1.0, the Javascript version is now feature complete. Only some more fine tuning seperates this RC from being RTM!
    To download version 1.0 RC1, go here.

    Next is version 1.1, which is more interesting to developers. If you are developing using 1.1, you are advised to upgrade to this "alpha-refresh". This version also includes the runtime of 1.0 RC, so there is no need to install both!
    To download, click here.

    Some tools you might be interested in if you are developing for Silverlight:

      Posted on: Saturday, July 28, 2007 9:50:37 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     May 22, 2007    

    If you use Silverlight 1.1 (the alpha version), you may have noticed that it's harder to see the source of the application, which was easy with WPF/E or Silverlight 1.0.
    Ernie Booth of the MSDN team therefore developed a plugin for Reflector that you can easily point to a site that uses Silverlight. It will load up the assemblies that the site uses.

    You can download it here.

      Posted on: Wednesday, May 23, 2007 12:09:30 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     May 21, 2007    

    Today, I got a mail with tons of Silverlight resources. I thought I'd post it for you to enjoy! I have not had the time to check them all out though...

    bits & bytes

    · Get silverlight

    · Telerik RadControls – 3d virtual rooms using control based framework

    · DLR & IronPython

    · Silverlight developer reference “poster”

    · Forums – installation, troubleshooting

    · Electric rain harmony (coming summer 2007) – flash to silverlight converter

    · Silverlight 1.0 Beta QuickStarts

    · Silverlight 1.1 Alpha QuickStarts

    sites

    · Main Microsoft site

    · Community site

    · Mix conference

    experiences & demos

    · Getting started with silverlight - Scott Guthrie demos how to build an app from scratch

    · "How Do I?" with Silverlight 1.0

    · "How Do I?" with Silverlight 1.1

    · Using Blend with Silverlight 1.0

    · Community gallery

    · Top 3 samples in community gallery

    o Silverlight Pad

    o Page Turn

    o Video Library

    · Beijing Olympics Use Silverlight

    · Channel 9 screencasts

    · Watch movie trailers & videos via Silverlight

    · How to do Rich media advertising - example using eyeblaster

    blogs

    · Scott Guthrie – no intro needed

    · Jim Hugunin - chief architect of the DLR

    · Mike Harsh – silverlight team

    · Lutz Roeder – Expression Blend team

    · Delay  of silverlight airlines demo

    · Ironpython

    tech talks

    · All recorded mix07 sessions

    · ScottGu’s mix keynote and great overview

    · ScottGu’s Channel9 interview

    · Building Rich Web Experiences using Silverlight and Javascript for Developers

    · Deep Dive on Silverlight Media Integration

    · Developing ASP.NET AJAX Controls with Silverlight

    · Creating and Delivering Rich Media and Video on the Web with Silverlight, Expression Studio, and Windows Server

    · Building Silverlight Applications using .NET (Part 1)

    · Building Silverlight Applications using .NET (Part 2)

    · Extending the Browser Programming Model with Silverlight

    · Just Glue It! Ruby and the DLR in Silverlight

    papers

    · Getting started whitepaper

    · Silverlight Architecture Overview

      Posted on: Monday, May 21, 2007 11:12:51 PM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     May 16, 2007    

    Telerik, known for their ASP.net and forms controls, just released a preview of their Silverlight controls.

    The RadControls for Silverlight preview comes with five "fundamental building blocks" -- Button, Image, Media, Label and CustomElement -- and two composite controls, StripLayoutPanel and Cube. Each of these seven controls comes with a set of client- and server-side events, can be added to an existing XAML file and can also be integrated with ASP.NET AJAX. An animation extender is also available.

    Go here for more information and here for the online demonstration.

      Posted on: Wednesday, May 16, 2007 4:27:23 PM (Romance Daylight Time, UTC+02:00)   |   Comments [2]
             
    Gill Cleeren     Silverlight     May 13, 2007    

    When I got home from Mix07, the first thing I did was extracting the Virtual PC of Visual Studio Orcas. I installed the tools needed for developing Silverlight 1.0 and 1.1 applications.

    While the applications I made in 1.0 worked fine, the simplest application I made in 1.1 Alpha did not, not even a "Hello World" would appear on screen.
    After some thinking, I figured out what was wrong.

    In Internet Explorer, go to Internet options > Security. Click on "Default level", which will lower the security settings (setting them to default level actually sets them to "Medium). These changes actually let Silverlight 1.1 run on Windows 2003 server.

      Posted on: Sunday, May 13, 2007 11:09:06 AM (Romance Daylight Time, UTC+02:00)   |   Comments [0]
             
    Gill Cleeren     Silverlight     April 16, 2007    

    Earlier than expected, Microsoft announced the new name of WPF/E, and it's a nice one! Silverlight. A lot of info can be found here: http://www.microsoft.com/silverlight/default_01.aspx, here: http://msdn.microsoft.com/silverlight and here: http://www.silverlight.net .

    After "Windows Presentation Foundation", I think this name really sounds a lot better and makes it easier to compare it with Flash. Also, the name removes the connection more or less with WPF (which is a good thing since they "only" have XAML in common).

    Way to go, Silverlight! (Actually Silverlight and Snowball go along fine...)

    Press release:

    LAS VEGAS — April 15, 2007 — Today at the 2007 National Association of Broadcasters conference (NAB2007), Microsoft Corp. unveiled Microsoft® Silverlight™, a new cross-browser, cross-platform plug-in for delivering the next generation of media experiences and rich interactive applications (RIAs) for the Web. Early supporters of the new platform include Akamai Technologies Inc., Brightcove Inc., Eyeblaster Inc., Limelight Networks, Major League Baseball and Netflix Inc.

    Microsoft Silverlight, previously called Windows® Presentation Foundation Everywhere (WPF/E), integrates with existing Web technologies and assets to provide higher-quality experiences with lower costs for media delivery. Delivered to end users through a seamless, fast installation, Silverlight offers consistent experiences to both Macintosh and Windows users on a variety of browsers including Internet Explorer®, Firefox and Safari.

    “Content providers are seeking a way to deliver rich interactive applications using the tools and skills they already have. They want an end-to-end solution that enables them to rapidly reach multiple platforms with reasonable deployment costs,” said Bob Muglia, senior vice president of the Server and Tools Business at Microsoft. “Microsoft Silverlight delivers on this need and marks a real step forward for the industry. Silverlight is the only solution in the market today that enables content creators to tap into the broad ecosystem for Windows Media® technologies while taking the Web’s rich interactive application experience to new levels.”

    Leading media companies and solution providers have announced support for Silverlight including Akamai Technologies, Brightcove, Eyeblaster, Limelight Networks, Major League Baseball, NaviSite Inc., Netflix, Pinnacle Systems Inc., Rhozet Corp., Skinkers, Sonic Solutions, Tarari Inc., Telestream Inc. and Winnov. All have indicated plans to deliver Silverlight-based experiences for their viewers and customers.

    “We’ve consistently heard from the media companies that they want the ability to easily implement key technologies for Internet video and rich broadband experiences,” said Bob Mason, chief technology officer at Brightcove. “With the release of Silverlight, Microsoft is bringing rich interactive experiences coupled with the VC-1 video standard into the browser, and we’re excited to announce plans to support this technology and continue to give our customers access to the cutting-edge technologies that will drive the growth of Internet TV.”

      Posted on: Monday, April 16, 2007 9:41:58 PM (Romance Daylight Time, UTC+02:00)   |   Comments [1]
             
    9/2/2010   9:31:10 PM