Archive | May, 2011

Slides from my Silverlight 5 talk

25 May

Tonight I’m doing a talk at “Silverlight developers in Denmark” (SLDEV). The talk will focus on the new features in Silverlight 5 and I promise I will bring lots of demos.

You can download the slides here.

by xamlgeek 
@xamlgeek

Silverlight 5 – Default file name in SaveFileDialog

25 May

A long requested feature coming with Silverlight 5 is the opportunity to set the default file name in the SaveFileDialog. In previous versions of Silverlight this missing feature have resulted in some bad user experiences, but finally it is here and it is easy to use.

To demonstrate it I have create a demo writing a text file to the computer allowing the user to set the default file name from the very beginning.

2011-05-25_013727

When the user clicks the Save-button the SaveFileDialog is shown and the user can save the file locally on the computer. The text from the TextBox is parsed to the SaveFileDialog as the default file name.

2011-05-25_013804

In the code I have set the Filter, the DefaultExt and the DefaultFileName on my SaveFileDialog instance. This provide an optimal experience for my user when saving files.

2011-05-25_013908

You can download the demo here.

by xamlgeek 
@xamlgeek

Silverlight 5 – Debugging bindings in XAML

24 May

One of the cool new tool features in Silverlight 5 is the XAML debugging features. It is limited to debugging bindings in XAML but that is an extremely useful feature.

I have created a demo showing the few steps needed to debug bindings in XAML. The demo consist of a TextBox containing a number a Button to refresh the number. The number is a random number.

2011-05-25_000737

2011-05-25_001716

The Text property of the TextBox binds to a property called “Number”. It is a Dependency Property defined in my code-behind. To make the binding work I have set the DataContext of the page to its self.

2011-05-25_002003

Whenever the Number property is updated it will automatically update the Text value on the TextBox.

As simple as it is I can spend hours looking for errors if I e.g. misspell the property that we use to bind to. Before Silverlight 5 I would get a hint in the Output window if I had a BindingExpression exception. In Silverlight 5 I can add a breakpoint to the binding directly in the XAML.

2011-05-25_003039

Debugging the XAML above I get an exception with a BindingExpression path error and enables me to easily identify the error.

2011-05-25_003230

You can download the sample here.

by xamlgeek
@xamlgeek

Follow

Get every new post delivered to your Inbox.

Join 1,356 other followers