Showing posts from July, 2010

Silverlight 4.0 Tutorial (5 of N): More Blend!

Read Previous Posts: Part1 , Part2 , Part3 , Part4 Continuing our series for building a registration booth application using Silverlight 4.0, in this post we will continue working with Expression Blend - Open Home.xaml, select the LayoutRoot grid in the Objects and Timeline window, set the Width and Height properties to Auto so that the grid takes all the screen size. - Now we will change the background color of the page, select the LayoutRoot grid, go to the Background property and select the Gradient Brush option. - The Gradient brush we will use will have three gradient stops, you can click on the gradient bar (below the color mixer) to add a gradient stop at the specified offset, to remove a gradient stop click, hold, and drag your mouse off the gradient bar. for each gradient stop you can specify the color (RGB, Alpha). - The xaml for the grid background will be as follows. < Grid.Background >         < LinearGradientBrush EndPoint ="

Silverlight 4.0 Implicit Styles: Not so implicit after all!

Silverlight 4.0 allows you to define implicit styles that are applied automatically to all controls of the type specified in the Style TargetType property, you can create an implicit style by creating a Style without any key, for example here is an implicit style for the TextBlock control < Style TargetType ="TextBlock">                          < Setter Property ="FontFamily" Value ="Freestyle Script" />                          < Setter Property ="FontSize" Value ="30" />                      </ Style > This style will be applied to all the TextBlocks that don’t define an explicit style, excellent.. right?, unfortunately this will not work for the controls defined inside a Template, for example if you have a  DataTemplate that contains a TextBlock, the TextBlock will not pick the implicit style, Microsoft explains the behaviour “Templates are viewed as an encapsulation boundary when loo

Silverlight 4.0 Tutorial (4 of N): ListBox ItemTemplate

Read Part 1 Read Part 2 Read Part 3 Continuing our RegistrationBooth Application, if you take a look at what we ended with you will find that the attendees data grid that we have is not user friendly, our application should be more attractive to the users, so we will get rid of the data grid and we will use a List box that has a custom template for displaying attendees, in this post we will start using Blend to assist in designing the application UI - Right click the xaml file in Visual Studio and choose Open in Expression Blend , this will open your solution in Blend. - Delete the attendeeDataGrid from the Home.xaml file. - We will change the layout of the form we will use a grid with two columns the width of the first one is about third of the screen width and we will put the list box in this column, and the second column take the remaining screen width and this is where we will put the attendees data form. - To do this, go to the Objects and Timeline window (if not

Silverlight 4.0 Tutorial (3 of N): Working with the DataForm Control

Read Part 1 Read Part 2 Continuing our RegistrationBooth Application, in the previous post we ended having a data grid that displays all the attendees, and a user control to add a new attendee. The user control for adding a new attendee didn’t contain any validation logic, of course this is a bad practice, in this post we will add the necessary validation when creating adding new attendees. - First we will need to define our validation logic for the Attendee entity, if you remember our first post when we created the Domain Service class we choose to create metadata classes for our entities, you can read more about metadata classes in the RIA services documentation ( How To Add Metadata Classes ). - In the RegistrationBooth.Web project the file RegistrationDomainService.metadata.cs contains the metadata classes, we will change the AttendeeMetadata class to add some validation attributes to the different Attendee properties, you can read more about validation attributes at How To Valida