Silverlight 3 Released and Introduction to DataForm
Silverlight 3 has been officially released last Friday. ScottGu's blog and Silverlight.net have the details on the exciting new features and capabilities delivered in Silverlight 3. Visit the Get Started page on Silverlight.net to get all you need for developing in Silverlight 3.
One of the new features that I worked on in Silverlight 3 is the DataForm control. Forms are widely used in many applications, and the Silverlight DataForm provides a powerful form out of the box that is easily customizable. It provides a flexible way to display a single object of or collection of data in a form and to interact with the object(s). It allows IEditableObject support, for the committing or cancelling of changes; it allows field- and entity-level validation through the consumption of attributes such as [Required]; and it allows navigation, should the form's binding be to a collection of data.
Here are some examples of using the DataForm:
Example 1: This is a basic DataForm with the default features out of the box. It has its ItemsSource set to a List of entities which has validation.
XAML:
<dataformToolkit:DataForm ItemsSource="{StaticResource EmployeeList}" />
Example 2: This shows 2 DataForms. The DataForm on the left is the same one from Example 1. The DataForm on the right is bound to the first DataForm by setting its CurrentItem using element name binding, and auto-generates its public properties so it works like a property grid.
XAML:
<dataformToolkit:DataForm ItemsSource="{StaticResource EmployeeList}" x:Name="dataForm1" />
<dataformToolkit:DataForm CurrentItem="{Binding ElementName=dataForm1}" Grid.Column="1" />
Example 3: This shows the many possibilities of using the DataForm control, such as Master-Details scenarios with the DataGrid, and usage with various other data sources and controls.
For more working examples, visit the Silverlight Toolkit Samples.
Hope this helps!
Ricky
Comments
Anonymous
July 15, 2009
It sounds to me like you might be the guy that knows the behaviour of the DataForm. I have used the DataForm in a list (grid), detail (DataForm) and there are three keys to other entities in one entity. I am trying to use ComboBoxes in the DataForm to display the names instead of keys. In this example there is the "experiment" that has Navigation Properties of "personnel" and a couple others. I tried using: <dataFormToolkit:DataField> <ComboBox x:Name="cmbPI" ItemsSource="{Binding personnel.pi_name}" /> </dataFormToolkit:DataField> The result was the name that I thought should have been displayed in the field was displayed in the drop down as a series of letters, one to each field. It looked up the correct name, but was using it as all the selections instead of showing the name in the field and the drop down showing all the people, allowing one to be selected when editing. Is the DataForm ComboBox designed to do this kind of data lookup, or is this something that is a possible future?Anonymous
July 15, 2009
The comment has been removed