Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Microsoft Silverlight 5 is a rich application framework for creating high-performance, cross-platform desktop and mobile applications. In this course, author Walt Ritscher demonstrates how to build a variety of applications in Silverlight, with particular focus on building compelling business applications and delivering premium video and audio content. Developers will work with the C# programming language and Visual Studio Professional, as well as Expression Blend, a tool that simplifies creation of the interactive user interfaces expected in modern-day applications.
The DataForm is a control for editing a single row in a data source. It shows a customizable form with data entry controls for each field in the underlying data entity. You can bind the DataForm to a multi-row source, but you can only see one row at a time. For this demonstration, I'll use Visual Studio and a project called UsingTheDataForm. I'll start by looking at my data source classes. If you've seen some of the other movies in this chapter, you've seen the RentalHouse class. This has a slight modification from some of the other demos.
I have an enumeration called location, and I'm using that when I set my property here. It's for the Location properties using the Location enumeration. And then my RentalManager class is just instantiating those types again, and it's using that brand-new enumeration value here. So that's my source. I'm going to go to this BasicForm and I'm going to add a DataForm. This is what the DataForm looks like before it's bound. It's just a white rectangle. In my code behind I'm binding to a single house in the collection.
So this is a one-source DataForm, and this is what it looks like. That's very nice! It's created one column for the names of the field and one column for the data entry. It's determined the right types. This is a text box; this is a dropdown, because of the enumerated values; these are text boxes; and this is a checkbox. Now it is templatable, so I could go in and change this text box and say I don't want a text box. I don't have any image control. Another thing that you can do with the DataForm is bind to a list of data.
Here's an example, BindToList. The same basic UI. I'm saying bind to an ItemSource, and then in the code behind, I'm binding it to all the houses this time. The main difference when you run the application is you get this VCR control up at the top. So now I can click on this to move to the next row, back a row, to the beginning of the data, and to the end of the data. It also has a Plus symbol and a Minus symbol, which add rows.
Click on OK and now I have a new row and I can delete a row. The nice thing about this VCR control is it's completely customizable. For my last demonstration, I'd like to show you a master detail form. In this example, I have a listbox which represents the master data and then as I click on a row, it takes the index from my listbox and uses it to find a particular record I need in the Detail section. You know how that works? Let me show you the code.
All right! Here we go! The ListBox is bound to the underlying data source. I'm telling it to display the marketing name of the underlying data. I've also set up an event procedure for SelectionChanged. The DataForm is bound to exactly the same source. Now when the user selects an item in ListBox, this event will fire. My code over here just does one thing.
It finds out the SelectedIndex in the ListBox, the number that's affiliated with the row that's selected, and takes that and passes it to the current index of the DataForm, which then looks up the data by index number. Now if you want to do other lookups, you can use CurrentItem. Now you would pass it a reference to an item and not an index number. It's quite simple to use the DataForm and it can save you time for basic forms over data. The DataForm is customizable with templates, which can dramatically change the appearance of your data-bound UI.
Find answers to the most frequently asked questions about Silverlight 5 Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.