This post is part of a string of posts found here: Learn Blend in a Month.
Blend 3 allows you to embed fonts, but unfortunately if you publish your work online you are technically distributing the font. This is illegal and could potentially land you in trouble.
However, there is a way around this, if you encrypt the font so that it is not usable then you are arguably not distributing it any more. This process is known as Obfuscation. It is important, however, to point out that you still need a license or permission to use a non-standard font in your work.
How to Obfuscate a font
First open up Microsoft Word (2007+), create a new document and type every character you will need in the font you require. Save the file as an XPS document and close Microsoft Word.
Locate the saved XPS document on your hardrive and rename the file type from ‘.xps‘ to ‘.zip‘. Now extract the contents of the .zip and find the file called ‘Resources‘, inside this folder should be a document with the file type ‘.odttf‘. Add this file into your Silverlight Solution and set its ‘Build Action‘ to ‘Resource‘.
Now the final part, in the XAML, locate your textBlock and set the ‘FontFamily‘ property to the .odttf file in your solution. Directly after this needs to be a ‘#‘ and then the exact name of how the font was displayed in the selection field in Microsoft Word. This allows you to have multiple fonts in one .odttf file.
The XAML should look similar to the below.
<TextBlock x:Name="textBlock" FontFamily="./Fonts/20FD640A-6B8C-569B-6B08-6F60BA7CC534.odttf#Segoe UI" FontSize="12" Foreground="Black" Text="text content goes here" />
Tags: Designers, Developers, Expression Blend, fonts, Learn-Blend-in-a-Month, Obfuscation, Silverlight 3, TextBlock, tutorial, Work environment, XAML
This post is part of a string of posts found here: Learn Blend in a Month.
If you are using multiple instances of elements then it may make more sense to think about making these elements User Controls. User Controls allow you to place objects into a container that can be re-used again and again, even multiple times at once. Every User Control has its own XAML file and its own code file.
To make a selection of elements on stage into a User Control it is really simple. First select all the objects you want to include in your new User Control, then right click anywhere on the selected objects. From the drop down options select ‘Make into UserControl…‘. This creates a new XAML file containing the objects you selected with it’s own code behind file too.
Each time you want to add a new instance of your User Control you will need to add the following XAML in…
<local:UserControlName Margin=”0,0,0,0″/>
Tags: controls, Designers, Expression Blend, Learn-Blend-in-a-Month, Silverlight 3, tutorial, Work environment, XAML
This post is part of a string of posts found here: Learn Blend in a Month.
Data Binding allows us to take the value from one object and apply it to another without needing to know a single line of code.
In this tutorial we are going to control the font size of a textBlock through the interaction of a Slider control. To start off we need to draw a Slider control and a textBlock on our stage as seen below.
To dataBind our Sliders value to our textBlocks font size we first need to select the Slider and go to the ‘
Properties‘ tab. Scroll down to the ‘
Common Properties‘ section and locate the ‘
Value‘ property. Click on the small square icon to the right of the field, this will bring up a menu, select ‘
Data Binding…‘.

This will bring up the Create Data Binding window. First select the ‘Element Property‘ tab (the middle tab). Now click on the object we want to effect (the textBlock), this will bring up a list of values that can be binded. We want to effect the font size so scroll down and select ‘FontSize‘. Finally we need to make sure the ‘Binding direction‘ is set to ‘TwoWay‘, expand the bottom area to change this setting.

Click ok to save these settings.
Now all that is left to do is to set the minimum and maximum values of our slider, these values will represent the font size range of our textBlock. To change these values go to the ‘Properties‘ tab and scroll down to the ‘Common Properties‘ section. We should end up with the following functionality.
You can see a more complex example of data binding in this
previous post of mine.
Tags: controls, Designers, Expression Blend, Learn-Blend-in-a-Month, Silverlight 3, tutorial, User Input, Work environment