I attended the Silverlight 3/Expression Blend 3 Launch event today held in San Francisco. There were a few good demos, but the one that interested me the most was the Blend 3 SketchFlow Demo given by Jon Harris. I got chance to sit up front and record it.
Here’s the unofficial demo video. I broke it up into two parts due to Youtube’s 10 minute limitation.
SketchFlow Demo Part I
Jon demos the SketchFlow map, design surface, and sample data features. In the end of this video, he show’s SketchFlow documentation and annotation features.
SketchFlow Demo Part II
In this demo, Jon demos bringing a pen and paper drawing to life with interactivity from SketchFlow. Awesome!
I often forget that font size is pixel-based instead of point-based when working with Silverlight. Designers using Expression Design will set the point size for Text fonts because that’s what available to them.
When implementing a design that was created using Expression Design, I need to convert the point values for fonts to pixel values for the fonts to be rendered accurately as designed. Traditionally, a point is 1/72 of an inch. A Silverlight pixel renders at 1/96 of an inch. To convert a point to a pixel, I need to multiply the point by 96/72 or 1.333….
Here’s a handy chart that I use.
Point (pt)
Pixel (px)~
7pt
9.333
8pt
10.666
9pt
12
10pt
13.333
11pt
14.666
12pt
16
13pt
17.333
14pt
18.666
15pt
20
Note that this is not an issue with setting FontSize for TextBlocks in WPF. With WPF, the FontSize value can be set with the “pt” unit qualifier and no conversion is necessary. Unit qualifiers are not supported in Silverlight 2.
Instead of naming a brush resource as MainWindowBackgroundBrush, they would use the name Background_MainWindow. At first, this may seem like an odd convention, especially with the underscore. However taken as a whole, this convention can be really useful in Expression Blend.
During the implementation process when applying brushes to WPF elements, the brushes can be quickly and easily set. Just select Brush Resources and find the correct brush. Since the brushes are in alphabetically order, all of the background brushes are in the same area. Likewise for the border and foreground brushes.
Also with this convention, we can remove the “Brush” word in the name since we can easily tell that a resource is a brush because the brush resources start with Border_, Background_, or Foreground_.
I think I will start following this naming convention in future WPF and Silverlight projects.
Do you commonly check whether code is being run in Blend or in the Visual Studio design surface? Often times, this is necessary to load up sample data or to prevent code that could potentially break the “Blendability” of a WPF or Silverlight app.
In WPF, you can call the DesignerProperties.GetIsInDesignMode for it. In Silverlight, you can check for HtmlPage.IsEnabled property.
I check for design mode often and needed a simple, consistent method to mask the DesignerProperties call in WPF. In Silverlight, I wanted to hide the hacky HtmlPage.IsEnabled check and change it from being a not(!) check to a positive check. Also, when Silverlight support the DesignerProperties.GetIsInDesignMode method, I can just easily change my check in one place. With some refinements from friends at work, I condensed it to a single static property in App.xaml.cs that I can use throughout my application.