“Expression Blend for Silverlight Developers” (DevDays, Holland)

I did a fun talk on Expression Blend at the recent DevDays conference at the Hague in Holland.

The basic idea of this talk was to (as much as possible in 75 minutes) take Expression Blend from scratch through to putting something together that involved things like;

  • layout, resources, styles, data-binding, sample data, behaviors/actions/triggers, visual states and animations, control templating, fluid layout, fluid movement

The recording of the talk is now on Channel9 – I’ve embedded the video here;

but unless your bandwidth is good enough you might want to download a higher definition video to watch offline as we spend quite a lot of time in Blend and it’s an environment that demands high resolution so a blurry video won’t help at all. Here’s the page for the download;

There are not really any slides in this talk, it’s just done inside of Blend and there are 3 main sections in case you want to jump around;

  • 4min 25s: Basic lap around the environment
  • 25min: Digging in to a few areas like styles, resources, etc.
  • 48min 20s: Demo putting together what we’ve learnt to build a “shopping cart” style UI

As an aside, I put together a lot of blog posts in this area so if you want to dig in and read some more then try;

and don’t forget the “learn Blend in 5 days” materials that you can jump to by clicking on the big banner image below;

image

Enjoy Smile

Update 10th May 2011 – a number of people asked me for the code for the library that I use in the latter part of the session in order to build up a little UI with some data and some commands and so on.

Here’s that library for download (including source)

A quick word about that library – it contains a bunch of product descriptions, images and so on that I load from an XML file. To give credit, I borrowed these images and most of the XML metadata from the “Silverlight Store” sample that you can find on the Silverlight.net site. I needed some data in a hurry and this seemed like a good way to get some re-use rather than to have to start from scratch.

Blend Bits 27–“Make it Flip”

This one comes from showing Blend to a few people yesterday and trying to think of various scenarios for making use of different visual states for a UI or for a control and one that came up was “can you make one of those UIs where we have a panel with data on the front and data on the back and it flips over”.

I declined to attempt to do this in front of people because I know it’s a little fiddly so I did it instead on a train journey.The output is below;

I started with some sample data;

image

I’ve been through making sample data before and the definition of my data here is pretty simple;

image

and I quickly added a DataGrid and bound it up to this data (I made the sample data available at run time too);

image

and so that’s relatively easy. I also brought in the Silverlight charting controls and created a chart to display the sales data for each salesperson;

image

I always struggle a little with the charts from the toolkit because they’re pretty complex controls – what I did here was set up the Chart’s ColumnSeries so that its ItemsSource is data-bound to my sample data and made sure that the 2 axes are set up correctly. In XAML, this looks like;

<toolkit:ColumnSeries 
  Title="Sales" 
  ItemsSource="{Binding Collection}" 
  IndependentValueBinding="{Binding Name}" 
  DependentValueBinding="{Binding Sales}"/>

where I’m displaying Sales on the Y axis and Name on the X axis. The only other “unusual” thing here is that I wanted my labels rotated on the X-axis and I had to go back to the source on that one to remember how it was done and I end up with something like;

<toolkit:Chart.Axes>
				<toolkit:CategoryAxis Orientation="X">
					<toolkit:CategoryAxis.AxisLabelStyle>
						<Style TargetType="toolkit:AxisLabel">
							<Setter Property="Template">
								<Setter.Value>
									<ControlTemplate TargetType="toolkit:AxisLabel">
										<toolkit:LayoutTransformer>
											<toolkit:LayoutTransformer.LayoutTransform>
												<RotateTransform Angle="-60"/>
											</toolkit:LayoutTransformer.LayoutTransform>
											<TextBlock Text="{TemplateBinding FormattedContent}"/>
										</toolkit:LayoutTransformer>
									</ControlTemplate>
								</Setter.Value>
							</Setter>
						</Style>
					</toolkit:CategoryAxis.AxisLabelStyle>
				</toolkit:CategoryAxis>
				<toolkit:LinearAxis Orientation="Y"/>
			</toolkit:Chart.Axes>

for my axes.

That’s all good – I’ve now got 2 pieces of content my DataGrid and my Chart both occupying the same place on the screen at the same time.

By default, I want to show my DataGrid and have my Chart away in the background somewhere so I made sure that it is behind my DataGrid;

image

and set up transformations on the Chart so that it is projected to be rotated by –180 degrees;

image

and scaled down;

image

and so by default my user will see the DataGrid and not the Chart. I then set up a couple of visual states for the control (I wrote about visual states previously);

image

my “normal” state is already defined. This is the state when the Grid is at the front and the Chart is at the back. Now, I want to define my chartToFront state and I do that by recording that state and making some property changes. Firstly on my DataGrid I want to rotate it, scale it and offset it a little;

image

image

and then I want my Chart object to rotate around to –360 degrees and grow to its full size;

image

Making these property changes “kind of works” in that when my control now transitions from the “normal” state to the “chartToFront” state, all the right things happen. The problem is that they all happen at once and that’s not really what I want. So, I manipulated the transition into my “chartToFront” state;

image

now, by default what’s Blend for me looks like this (note that  the 3 second period here is exaggerated);

image

so, clearly, everything’s happening here but I want to control the order so a little manipulation is called for;

image

and so now you can see that the ordering goes something like this;

  1. Scale down the DataGrid
  2. Rotate the DataGrid and the Chart at the same time.
  3. Translate the DataGrid “into the screen” halfway through the rotation.
  4. Scale up the Chart at the end.

and that works quite nicely. The only “problem” is that going back from this state to the “normal” state simply reverses the various property changes and so I probably want to control that transition as well;

image

and so I can edit that one in a similar manner;

image

I’m not 100% sure whether I’m doing these on the right transitions here so feel very free to post comments on this post and say “no,no, you should have done this in a different way” – I’m fairly robust, I can take the constructive criticism Winking smile

I added a couple of buttons to drive the state transitions and simply used GoToStateAction to drive the state transitions;

image

and I wrote a little about actions, triggers, behaviours previously.

I put the project file here for download in case you want to open it up and play around.

Blend Bits 26–Use Libraries for Assemblies

One of the things that’s a bit annoying with Expression Blend is that when you go to reference an assembly you get the standard Windows file open dialog. That is;

image

raises the dialog;

image

and that’s not what you see in Visual Studio and makes hunting down the assemblies that you want a little more “tricky”. What I tend to do is to use a Windows 7 library to add all the locations for my typical assemblies and then it makes it relatively easy to find what I want – at the time of writing mine looks like this;

image

and so when I’m hunting for the charting library from the toolkit I just need to bang in a search string;

image

and it’s pretty quick to locate it.