Documente Academic
Documente Profesional
Documente Cultură
http://msdn.microsoft.com/en-us/library/ee621313
Note
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
Prerequisites
You need the following components to complete this walkthrough: Visual Studio 2010. Access to a running instance of SQL Server or SQL Server Express that has the AdventureWorksLT sample database attached to it. You can download the AdventureWorksLT database from the CodePlex Web site. Prior knowledge of the following concepts is also helpful, but not required to complete the walkthrough: WCF Data Services. For more information, see ADO.NET Data Services Framework Overview. Entity Data Models and the ADO.NET Entity Framework. For more information, see Entity Data Model and Introducing the Entity Framework. Working with the Silverlight Designer. For more information, see Silverlight Tools. Silverlight data binding. For more information, see Data Binding.
1 of 9
5/25/2012 11:53 AM
http://msdn.microsoft.com/en-us/library/ee621313
2 of 9
5/25/2012 11:53 AM
http://msdn.microsoft.com/en-us/library/ee621313
Note
In Visual Basic projects, the solution node only appears in Solution Explorer when the Always show solution check box is selected in the General, Projects and Solutions, Options Dialog Box. 2. In the New Project dialog, expand Visual C# or Visual Basic, and then select Silverlight. 3. Select the Silverlight Application project template. 4. In the Name box, type AdventureWorksSilverlightApp and then click OK. 5. In the New Silverlight Application dialog box, click OK.
3 of 9
5/25/2012 11:53 AM
Walkthrough: Binding Silverlight Controls to a WCF Data Service 2. In the Data Sources window, click Add New Data Source. The Data Source Configuration Wizard opens.
http://msdn.microsoft.com/en-us/library/ee621313
3. In the Choose a Data Source Type page of the wizard, select Service and then click Next. 4. In the Add Service Reference dialog box, click Discover. Visual Studio searches the current solution for available services, and adds AdventureWorksDataService.svc to the list of available services in the Services box. 5. In the Namespace box, type AdventureWorksService. 6. In the Services box, click AdventureWorksDataService.svc and then click OK. 7. In the Add Service Reference page, click Finish. Visual Studio adds nodes that represent the data returned by the service to the Data Sources window.
<Grid.RowDefinitions> <RowDefinition Height="75" /> <RowDefinition Height="525" /> </Grid.RowDefinitions> <Button HorizontalAlignment="Left" Margin="22,20,0,24" Name="backButton" Width="75" Content="< <Button HorizontalAlignment="Left" Margin="116,20,0,24" Name="nextButton" Width="75" Content="&g 3. Build the project.
4 of 9
5/25/2012 11:53 AM
Walkthrough: Binding Silverlight Controls to a WCF Data Service PasswordHash PasswordSalt rowguid
http://msdn.microsoft.com/en-us/library/ee621313
This prevents Visual Studio from creating controls for these nodes when they are dropped onto the designer. For this walkthrough, it is assumed that the end user does not want to see this data. 4. From the Data Sources window, drag the Customers node to the designer under the buttons. Visual Studio generates XAML and code that creates a set of controls that are bound to the customer data.
5. Replace the event handler with the following code. Make sure that you replace the localhost address in this code with the local host address on your development computer: C# private AdventureWorksLTEntities advWorksService; private System.Windows.Data.CollectionViewSource customersViewSource;
5 of 9
5/25/2012 11:53 AM
http://msdn.microsoft.com/en-us/library/ee621313
Important
If a security exception occurs, verify that the following conditions are true: The port number used in step 5 of the previous procedure matches the port number of your ASP.NET Development Server. AdventureWorksWebApp is set as the startup project. AdventureWorksSilverlightAppTestPage.aspx is set as the start page. 4. Close the application.
Navigating Records
Add code that enables scrolling through records by using the < and > buttons.
3. Return to the designer, and double-click the > button. Visual Studio opens the code-behind file and creates a new nextButton_Click event handler. 4. Replace the generated nextButton_Click event handler with the following code: C#
6 of 9
5/25/2012 11:53 AM
http://msdn.microsoft.com/en-us/library/ee621313
Note
If you see an error here verify the code contains the correct port for your ASP.NET Development Server.
Next Steps
After completing this walkthrough, you can perform the following related tasks: Learn how to save changes back to the database. For more information, see Data Binding. Learn how to incorporate more features using WCF Data Services in Silverlight applications. For more information, see ADO.NET Data Services (Silverlight).
See Also
Other Resources Data Access and Data Structures
Change History
Date
History
Added troubleshooting suggestions.
Reason
May 2011
Customer feedback.
7 of 9
5/25/2012 11:53 AM
http://msdn.microsoft.com/en-us/library/ee621313
Yes
No
Community Content
How do you do t he update?
How do you make the update work? The link is broken. Would be nice if these were all tied together from start to finish with the same data source so those of use who are novices could figure it out. The Data Binding link is broken. 12/15/2010 RobKCMO
8 of 9
5/25/2012 11:53 AM
http://msdn.microsoft.com/en-us/library/ee621313
8/24/2010 rj4net
9 of 9
5/25/2012 11:53 AM