October 28th, 2009

Using Data Binding to share data in Blend

Silverlight Blend Tutorials, Working with Silverlight, by Gavin Wignall.

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.

Back Top

Responses to “Using Data Binding to share data in Blend”

  1. No comments yet.
  1. Learn Expression Blend in a Month! » Silverlight Buzz (,November 15, 2009)

    [...] Using Data Binding to share data in Blend [...]

Leave a Reply

Back Top