<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Visual Studio Data : Data Binding</title><link>http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx</link><description>Tags: Data Binding</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>The Data Source Window Support in WCF RIA Services</title><link>http://blogs.msdn.com/vsdata/archive/2009/12/01/the-data-source-window-support-in-wcf-ria-services.aspx</link><pubDate>Tue, 01 Dec 2009 05:12:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9930570</guid><dc:creator>XiaoyingGuo</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9930570.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9930570</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9930570</wfw:comment><description>&lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;WCF RIA Services Beta was announced at PDC09 one week ago. It contains a lot of runtime support to make the experience of building a web business application much easier using Silverlight. Besides, there are also some tooling supports to help developers write less trivial code but to make the application work as expected. The Data Source Window support is one of them to help setting business objects data binding onto UI controls in a second. Actually, it is not a new concept in other technologies. The Data Source Window support for data-binding has been working for different technologies in VS2010, including WPF and WinForms. This article will use a simple application to show you how to leverage the Data Source Window support to do data-binding through a couple of drag-and-drops in WCF RIA Services scenarios.     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font size="2"&gt;Get ready to the project       &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;To try it out, you need to install the &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=177508"&gt;&lt;font size="2"&gt;WCF RIA Services Preview&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; on VS2010 Beta2, which works on Silverlight 4.&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;Then follow the steps below to display your business objects into the Data Source Window:      &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; mso-list: l1 level1 lfo1" class="MsoListParagraphCxSpFirst"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Create a new Silverlight 4 Application, and check “Enable .NET RIA Services” in the New Silverlight Application Wizard. The project template and wizard will create a client project and a server project with WCF RIA Services enabled.&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; mso-list: l1 level1 lfo1" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;On the Server project, add ADO.NET Entity Data Model item. Here the example uses Employee and EmployeeAddress tables in the AdventureWorks database. &lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; mso-list: l1 level1 lfo1" class="MsoListParagraphCxSpLast"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;3.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Build the solution and add a new DomainService class into the Server project. Let’s call it EmployeeService and add the following code into the file:          &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p style="line-height: normal; text-indent: 0.5in; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;public&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; &lt;span style="color: #2b91af"&gt;IQueryable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Employee&lt;/span&gt;&amp;gt; GetEmployees()      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;{      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;this&lt;/span&gt;.ObjectContext.Employees.Include(&lt;span style="color: #a31515"&gt;&amp;quot;EmployeeAddresses&amp;quot;&lt;/span&gt;).OrderBy(e=&amp;gt;e.EmployeeID);      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font size="2"&gt;Also add [Include] attribute on the EmployeeAddresses property in Employee object in the metadata file like below:&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; mso-bidi-font-size: 15.0pt"&gt;&lt;font size="2"&gt;[&lt;span style="color: #2b91af"&gt;Include&lt;/span&gt;]        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;public&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; &lt;span style="color: #2b91af"&gt;EntityCollection&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;EmployeeAddress&lt;/span&gt;&amp;gt; EmployeeAddresses;&lt;/span&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; mso-list: l1 level1 lfo1" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;4.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Build the solution. And now let’s open the MainPage.xaml and the Data Source Window through Data&lt;span style="font-family: wingdings; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: wingdings"&gt;&lt;span style="mso-char-type: symbol; mso-symbol-font-family: wingdings"&gt;à&lt;/span&gt;&lt;/span&gt;Show Data Source Window. You will see that the business objects added into the solution has been displayed in the Data Source Window now like below:          &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image002_4.png"&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image002_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image002_thumb_1.png" width="240" height="145" v:shapes="Picture_x0020_4" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p style="margin-left: 0in; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font size="2"&gt;Generate Employee details and EmployeeAddress data grid view       &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p style="margin-left: 0in; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;Suppose we want our UI to look like below to display Employee data and their EmployeeAddress information in a data grid view:&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin-left: 0in; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;Let’s go through each of control one by one:&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; mso-list: l2 level1 lfo2" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Adding an Employee details view with data-binding           &lt;p&gt;&lt;/p&gt;         &lt;/b&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;In the tree view of the Data Source Window, we can see the business objects and data fields are displayed together with control icons. The icons indicate which control will be generated after drag and drop to a container control (such as Grid, ScrollView, etc.) in the Silverlight designer surface. The Data Source Window set default controls based on the data type. From the picture above, we can see the default control for Employee is a DataGrid. But we definitely can change that by clicking the arrow button next to Employee:     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image004_4.png"&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image004_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image004_thumb_1.png" width="240" height="197" v:shapes="Picture_x0020_5" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;    &lt;p&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;Here, let’s choose Details in the drop-down list. We’ll see the icon has changed after clicking that:     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image006_4.png"&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image006_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image006_thumb_1.png" width="240" height="134" v:shapes="Picture_x0020_6" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;    &lt;p&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;The Data Source Window also allows us to add more control association&lt;span style="color: red"&gt;s&lt;/span&gt; (including user custom controls) with a type through Customize Control Browser:      &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image008_4.png"&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image008_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image008_thumb_1.png" width="240" height="200" v:shapes="Picture_x0020_7" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image010_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/TheDataSourceWindowSupportinWCFRIAServic_B991/clip_image010_thumb_1.png" width="240" height="197" v:shapes="Picture_x0020_1" /&gt;&lt;/a&gt;&lt;/span&gt;      &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpLast"&gt;&lt;font size="2"&gt;Now let’s drag the Employee node and drop it to the designer surface of MainPage.xaml. We will see the details view is generated for the Employee. Check the code in XAML, we’ll see the code is generated like below:     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 15pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;Grid&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; x&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;:&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;Name&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Background&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;White&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;riaControls&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;:&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;DomainDataSource&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; AutoLoad&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Height&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; LoadedData&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;employeeDomainDataSource_LoadedData&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Name&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;employeeDomainDataSource&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; QueryName&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;GetEmployeesQuery&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Width&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;0&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;riaControls&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;:&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;DomainDataSource.DomainContext&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;my&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;:&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;EmployeeContext&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; /&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;riaControls&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;:&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;DomainDataSource.DomainContext&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;riaControls&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;:&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;DomainDataSource&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&amp;#160;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;Grid&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; DataContext&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;Binding&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; ElementName&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=employeeDomainDataSource,&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Path&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=Data}&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; ....&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt 1in; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;....&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;TextBlock&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Text&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;Birth Date:&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; ....&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; /&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;TextBox&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Text&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;Binding&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Path&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=BirthDate,&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; Mode&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=TwoWay,&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; ValidatesOnExceptions&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=true,&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; NotifyOnValidationError&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;=true}&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; ....&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt; /&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt 1in; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;....     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;Grid&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;     &lt;p&gt;&amp;#160;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;Grid&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-bidi-font-size: 15.0pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;The DomainDataSource is generated, and the generated input controls set the binding path to the DomainDataSource so as to load data. The validation is also enabled in the binding path. &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;Run the application, we will see Employee data is loaded into the details view without writing any code. &lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; mso-list: l2 level1 lfo2" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Associate a DataPager with the Employee details           &lt;p&gt;&lt;/p&gt;         &lt;/b&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;To achieve this, you can follow the steps below:     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p style="text-indent: -0.25in; margin-left: 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;a)&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Drag and drop a DataPager from the Toolbox (if you don’t find it, you can add that by right-click the Toolbox and select Choose Items…) to the designer surface.       &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p style="text-indent: -0.25in; margin-left: 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;b)&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Drag and drop Employee node to the DataPager that is just dropped on the designer.       &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p style="text-indent: -0.25in; margin-left: 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class="MsoListParagraphCxSpLast"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;c)&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;In the property window, set PageSize of the DataPager to 1.       &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in" class="MsoNormal"&gt;&lt;font size="2"&gt;Now we can run the application and see how the DataPager works with the Employee details.     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; mso-list: l2 level1 lfo2" class="MsoListParagraphCxSpFirst"&gt;&lt;font size="2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;3.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Add EmployeeAddress data grid view which is corresponding to what is selected in the Employee details view&lt;/b&gt;          &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;To do so is pretty simple. The tree view also displays the relationships between business objects. For example, here we can see Employee has relationship with itself, as well as EmployeeAddress. Let’s drag and drop the EmployeeAddresses in the Employee tree to the designer surface. We will see a DataGrid is generated with columns customized through the Data Source Window. &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpLast"&gt;&lt;font size="2"&gt;Run the application. Now with each selected Employee, the DataGrid will display corresponding EmployeeAddress data.      &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;As a matter of fact, the Data Source Window supports more scenarios than this. It will save a lot of coding time on some trivial data-binding work if it’s fully made use of. To get more information about it, check the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee796239(VS.91).aspx"&gt;&lt;font size="2"&gt;walkthrough&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; on MSDN, which will help you get full understanding about this feature. Enjoy!     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9930570" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/RIA+Services/default.aspx">RIA Services</category></item><item><title>Integrate SharePoint List Data in Your WPF Application</title><link>http://blogs.msdn.com/vsdata/archive/2009/11/26/integrate-sharepoint-list-data-in-your-wpf-application.aspx</link><pubDate>Thu, 26 Nov 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9928946</guid><dc:creator>dubin</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9928946.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9928946</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9928946</wfw:comment><description>&lt;P&gt;With the &lt;A href="http://sharepoint.microsoft.com/Pages/Default.aspx" mce_href="http://sharepoint.microsoft.com/Pages/Default.aspx"&gt;SharePoint 2010 Beta&lt;/A&gt; came out of the door, one of the exciting news is that it allows developers to access SharePoint List Data using &lt;A href="http://blogs.msdn.com/adonet/archive/2009/09/01/ado-net-data-services-v1-5-ctp2-now-available.aspx" mce_href="http://blogs.msdn.com/adonet/archive/2009/09/01/ado-net-data-services-v1-5-ctp2-now-available.aspx"&gt;ADO.Net Data Service 1.5&lt;/A&gt;. If you are familiar with Data Service Client programming mode (we have already posted some articles &lt;A href="http://blogs.msdn.com/vsdata/archive/2009/10/22/accessing-master-detail-data-through-ado-net-data-service-in-a-silverlight-application-part-1.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/10/22/accessing-master-detail-data-through-ado-net-data-service-in-a-silverlight-application-part-1.aspx"&gt;here&lt;/A&gt;), it will be very easy to integrate SharePoint List Data in your application.&lt;/P&gt;
&lt;P&gt;Once you set up the SharePoint with ADO.Net Data Service (see How-To &lt;A href="http://blogs.msdn.com/astoriateam/archive/2009/10/21/using-data-services-over-sharepoint-2010-part-1-getting-started.aspx" mce_href="http://blogs.msdn.com/astoriateam/archive/2009/10/21/using-data-services-over-sharepoint-2010-part-1-getting-started.aspx"&gt;here&lt;/A&gt; ), you can check the Data Service through http://&amp;lt;SharePointServer&amp;gt;/_vti_bin/ListData.svc. Now we are going to show you how to program against the service in &lt;A href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Visual Studio 2010 Beta2&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;In Visual Studio 2010, developers can add Data Source to ADO.Net Data Service through &lt;A href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.100).aspx"&gt;Data Source Configuration Wizard&lt;/A&gt;, you can do the same thing for SharePoint Data service. Here we create a Visual Basic WPF Application, after launching the Wizard (Menu-&amp;gt;Data-&amp;gt;Add New Data Source), we can see a SharePoint entry as following.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image002_4.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image002_4.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image002 border=0 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image002_thumb_1.jpg" width=530 height=201 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image002_thumb_1.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;After selecting the SharePoint Icon and clicking “Next” button, “Add Service Reference” will be launched. Instead of remembering the long address of the service, you only need to input the SharePoint site (eg, my sample site is &lt;A href="http://vspro-vm-bdc1/" mce_href="http://vspro-vm-bdc1"&gt;http://vspro-vm-bdc1&lt;/A&gt; ) then click “Go” button. Visual Studio will heuristically find the service address for you. Once it’s populated, you can click “OK” button and finish adding the data source.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image004_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image004_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image004 border=0 alt=clip_image004 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image004_thumb.jpg" width=529 height=157 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image004_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image006_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image006_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image006 border=0 alt=clip_image006 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image006_thumb.jpg" width=528 height=303 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image006_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Then you can open the Data Source Window (Menu-&amp;gt;Data-&amp;gt;Show Data Source) and check the schema of the SharePoint List Data.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image007_2.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image007_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image007 border=0 alt=clip_image007 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image007_thumb.png" width=528 height=334 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image007_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;As same as other &lt;A href="http://blogs.msdn.com/vsdata/archive/2009/05/20/wpf-data-binding-creating-a-master-details-form-in-visual-studio-2010.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/05/20/wpf-data-binding-creating-a-master-details-form-in-visual-studio-2010.aspx"&gt;data sources&lt;/A&gt; we introduce before, we can drag the SharePoint Data Source from Data Source Window and drop to WPF Designer. It will generate the UI with Data Binding automatically.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image009_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image009_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image009 border=0 alt=clip_image009 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image009_thumb.jpg" width=530 height=274 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/IntegrateSharePointListDatainYourWPFAppl_13DC6/clip_image009_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you open the code-behind file (MainWindow.xaml.vb), you will notice Visual Studio has already generated the sample code so that you can simply follow the comment to fill the data.&lt;/P&gt;
&lt;P&gt;Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded&lt;/EM&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;Dim AnnouncementsViewSource As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("AnnouncementsViewSource"), System.Windows.Data.CollectionViewSource)&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;'Load data by setting the CollectionViewSource.Source property:&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;'AnnouncementsViewSource.Source = [generic data source]&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;End Sub&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;As we mentioned before, accessing SharePoint List Data is the same as other ADO.Net Data Service. The following is a sample code to load data using the default credential.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded&lt;/EM&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;Dim AnnouncementsViewSource As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("AnnouncementsViewSource"), System.Windows.Data.CollectionViewSource)&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;'Load data by setting the CollectionViewSource.Source property:&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;Dim Context As New SharePointReference.TeamSiteDataContext(&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;New Uri("http://vspro-vm-bdc1/_vti_bin/ListData.svc", UriKind.Absolute))&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;Context.Credentials = System.Net.CredentialCache.DefaultCredentials&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;AnnouncementsViewSource.Source = Context.Announcements.Execute().ToList()&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;End Sub&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;So far we have finished the simple application with the SharePoint List Data Source. Cheers!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9928946" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Sharepoint/default.aspx">Sharepoint</category></item><item><title>WPF Data Binding: How to Bind DataSet to WPF Designer</title><link>http://blogs.msdn.com/vsdata/archive/2009/11/13/wpf-data-binding-how-to-bind-dataset-to-wpf-designer.aspx</link><pubDate>Fri, 13 Nov 2009 05:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9921772</guid><dc:creator>Yaohai</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9921772.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9921772</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9921772</wfw:comment><description>&lt;H3&gt;WPF Data Binding: How to Bind DataSet to WPF Designer&lt;/H3&gt;
&lt;P&gt;In our previous posts, we mostly used the Entity Data Model as the ORM (Object-relational mapping) layer for the WPF Data Binding scenarios. &lt;/P&gt;
&lt;P&gt;Meanwhile, since DataSet is used broadly, we also provide the DataSet as a supported DataSource in the Data Binding stories. Following is a step-by-step example using C#. The example is based on Visual Studio 2010 Beta2 version. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Bind DataSet to WPF designer: &lt;/B&gt;&lt;/P&gt;
&lt;P&gt;1. Open Visual Studio. From the main menu: File-&amp;gt;New Project, choose WPF Application to create a new C# application. Here, we assume the project name to the default one: &lt;I&gt;WpfApplication1&lt;/I&gt;. &lt;/P&gt;
&lt;P&gt;2. From the main menu: Data-&amp;gt;Add New Data Source…-&amp;gt;DataBase-&amp;gt;Dataset to trigger Data Source Wizard. &lt;/P&gt;
&lt;P&gt;3. Follow the Wizard to connect to a Northwind SQL Server database, and choose tables: Customers, Orders. Following is what the Dataset designer looks like after this step finished: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/1_8.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/1_8.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=1 border=0 alt=1 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/1_thumb_3.png" width=600 height=385 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/1_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;4. From the main menu: Data-&amp;gt;Show Data Sources to show the Data Sources Tool Window, and make sure that MainWindow.xaml is the active window: &lt;/P&gt;
&lt;P&gt;5. Switch back to DataSources Tool Window, you can click on &lt;I&gt;Customers&lt;/I&gt; node and click the drop-down menu. On the context menu, choose “Customize…” to popup the “Customize Control Binding” dialog. Select the ComboBox for the [List] Data type: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_4.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_thumb_1.png" width=456 height=379 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;6. Bind the &lt;I&gt;Customers&lt;/I&gt; to the “Combobox” control. After above steps, following is the snapshot before the drag&amp;amp;drop operation. From its icon, you can see the &lt;I&gt;Customers&lt;/I&gt; is bound to Combobox now.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_thumb_2.png" width=580 height=342 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;7. Drag&amp;amp;drop the &lt;I&gt;Customers&lt;/I&gt; table to the top-left corner. Then, drag&amp;amp;drop the &lt;I&gt;Customers.Orders &lt;/I&gt;to the center of the WPF designer. To layout the controls as follow: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_8.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_thumb_3.png" width=505 height=316 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingHowtoBindDataSettoWPFDesig_C441/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;With these steps, a simple DataSet Master-Details application is created. Press “Ctrl + F5” to run the application and see the data. &lt;B&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Behind the Scenes: &lt;/B&gt;&lt;/P&gt;
&lt;P&gt;In step 5, there are two parts of code generated: One is the xaml markup code and the other is the C# code behind. The generated code is for demonstration purpose. Here, I will explain their corresponding meanings to provide guideline for modifying the code.&lt;/P&gt;
&lt;P&gt;Regarding the xaml code, besides the markups for the controls/data-binding, which are the same when using the EDM as the ORM layer, it also generates resources section for the Window: &lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Window.Resources&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt;my&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt;NorthwindDataSet&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow"&gt;="NorthwindDataSet" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;CollectionViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="customersViewSource"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Path&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;=Customers,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;={&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; NorthwindDataSet&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;}}" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;CollectionViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="customersOrdersViewSource"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Path&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;=FK_Orders_Customers,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;={&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; customersViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;}}" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: 21pt; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Window.Resources&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt; &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;The first line defines an object resource of the NorthwindDataSet instance, which is specific to DataSet. So when a Window is initialized, there will be a DataSet instance created. The 2&lt;SUP&gt;nd&lt;/SUP&gt; and 3&lt;SUP&gt;rd&lt;/SUP&gt; lines of code are doing master-details data-binding leveraging CollectionViewSource. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The generated C# code behind is: &lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Window_Loaded(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;WpfApplication1.&lt;SPAN style="COLOR: #2b91af"&gt;NorthwindDataSet&lt;/SPAN&gt; NorthwindDataSet = ((WpfApplication1.&lt;SPAN style="COLOR: #2b91af"&gt;NorthwindDataSet&lt;/SPAN&gt;)(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.FindResource(&lt;SPAN style="COLOR: #a31515"&gt;"NorthwindDataSet"&lt;/SPAN&gt;)));&amp;nbsp;&lt;/SPAN&gt; 
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Load data into the table Customers. You can modify this code as needed.&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;WpfApplication1.NorthwindDataSetTableAdapters.&lt;SPAN style="COLOR: #2b91af"&gt;CustomersTableAdapter&lt;/SPAN&gt; northwindDataSetCustomersTableAdapter = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; WpfApplication1.NorthwindDataSetTableAdapters.&lt;SPAN style="COLOR: #2b91af"&gt;CustomersTableAdapter&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;northwindDataSetCustomersTableAdapter.Fill(NorthwindDataSet.Customers); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;System.Windows.Data.&lt;SPAN style="COLOR: #2b91af"&gt;CollectionViewSource&lt;/SPAN&gt; customersViewSource = ((System.Windows.Data.&lt;SPAN style="COLOR: #2b91af"&gt;CollectionViewSource&lt;/SPAN&gt;)(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.FindResource(&lt;SPAN style="COLOR: #a31515"&gt;"customersViewSource"&lt;/SPAN&gt;))); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;customersViewSource.View.MoveCurrentToFirst(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Load data into the table Orders. You can modify this code as needed.&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;WpfApplication1.NorthwindDataSetTableAdapters.&lt;SPAN style="COLOR: #2b91af"&gt;OrdersTableAdapter&lt;/SPAN&gt; northwindDataSetOrdersTableAdapter = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; WpfApplication1.NorthwindDataSetTableAdapters.&lt;SPAN style="COLOR: #2b91af"&gt;OrdersTableAdapter&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;northwindDataSetOrdersTableAdapter.Fill(NorthwindDataSet.Orders); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;System.Windows.Data.&lt;SPAN style="COLOR: #2b91af"&gt;CollectionViewSource&lt;/SPAN&gt; customersOrdersViewSource = ((System.Windows.Data.&lt;SPAN style="COLOR: #2b91af"&gt;CollectionViewSource&lt;/SPAN&gt;)(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.FindResource(&lt;SPAN style="COLOR: #a31515"&gt;"customersOrdersViewSource"&lt;/SPAN&gt;))); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;customersOrdersViewSource.View.MoveCurrentToFirst(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Again, the 1&lt;SUP&gt;st&lt;/SUP&gt; line is getting the DataSet object instance from the WPF designer resource dictionary. The 2&lt;SUP&gt;nd&lt;/SUP&gt; line is loading the Customers data into the table. You can replace it with other DataSet object instance as you prefer. The 3&lt;SUP&gt;rd&lt;/SUP&gt; and 4&lt;SUP&gt;th&lt;/SUP&gt; lines are initializing the CollectionViewSource. The lines 5~7, which are for the table &lt;I&gt;Customers.Orders, &lt;/I&gt;are similar to lines 2~4.&lt;I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;You may notice that the data is loaded when the application starts. If you prefer to load it on demand, you can move this code to some other event handler such as a button click or something like that. &lt;/P&gt;
&lt;P&gt;Hope this helps. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9921772" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/Typed+Dataset/default.aspx">Typed Dataset</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category></item><item><title>Accessing Master-Detail Data through ADO.NET Data Service in a Silverlight Application (Part 2)</title><link>http://blogs.msdn.com/vsdata/archive/2009/11/07/accessing-master-detail-data-through-ado-net-data-service-in-a-silverlight-application-part-2.aspx</link><pubDate>Sat, 07 Nov 2009 10:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9919036</guid><dc:creator>XiangZeng</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9919036.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9919036</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9919036</wfw:comment><description>&lt;FONT size=3 face=Calibri&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;In &lt;A href="http://blogs.msdn.com/vsdata/archive/2009/10/22/accessing-master-detail-data-through-ado-net-data-service-in-a-silverlight-application-part-1.aspx"&gt;Part 1&lt;/A&gt; of this post, we developed our Silverlight application to access data through an ADO.NET Data Service. So far we are able to load the data at run time and navigate through the data records back and forth. Let’s now develop more functionality to update data, delete records, and add new records.&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;Updating Data Records&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;Our data is accessed through the Service Reference we added to our Silverlight application. However, the Service Reference does not keep track of the changes that we make in the application. This is actually due to a limitation of &lt;A href="http://msdn.microsoft.com/en-us/library/cc668789.aspx"&gt;&lt;FONT color=#0000ff&gt;ADO.NET Data Service Client Library&lt;/FONT&gt;&lt;/A&gt;. We have to have a mechanism to notify the DataContext object about changes.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In &lt;A href="http://blogs.msdn.com/vsdata/archive/2009/10/22/accessing-master-detail-data-through-ado-net-data-service-in-a-silverlight-application-part-1.aspx"&gt;Part 1&lt;/A&gt;, we added the data we retrieved through the service into an ObservableCollection&amp;lt;T&amp;gt; so that we can get notifications when data get added, updated or removed. We can then notify the DataContext by implementing System.ComponentModel.INotifyPropertyChanged on the DataContract classes. &lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;For example, in order to notify NorthwindEntities (the DataContext object) about changes of the CompanyName property of Customer (the DataContract object), we can do the following:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt; : &lt;SPAN style="COLOR: #2b91af"&gt;INotifyPropertyChanged&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;event&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventHandler&lt;/SPAN&gt; PropertyChanged;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; OnCompanyNameChanged()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (PropertyChanged != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;PropertyChanged(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventArgs&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"CompanyName"&lt;/SPAN&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;The OnCompanyNameChanged() partial method is defined (yet not implemented) in the generated Reference.cs file of the Service Reference. You can find this file in Solution Explorer under “Service References” – “NorthwindServiceReference” – “Reference.datasvcmap” – “Reference.cs”.&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;For this application, we are creating a class file “NorthwindEntitiesChangeManager.cs” in the Silverlight application. For every updatable property of Customer, Order, and Order_Details, we implement the On&amp;lt;PROPERTY&amp;gt;Changed partial&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;method in the same manner as above.&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;We’ll also need to notify the DataContext object about DataContract object changes. Therefore, we are modifying the OnDataLoadComplete method to hook up the change events:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; OnDataLoadComplete(&lt;SPAN style="COLOR: #2b91af"&gt;IAsyncResult&lt;/SPAN&gt; result)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&amp;gt; custs = qry.EndExecute(result).ToList();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt; cust &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; custs)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cust.PropertyChanged += &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventHandler&lt;/SPAN&gt;(cust_PropertyChanged);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt; ord &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; cust.Orders)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ord.PropertyChanged += &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventHandler&lt;/SPAN&gt;(ord_PropertyChanged);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt; od &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; ord.Order_Details)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;od.PropertyChanged += &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventHandler&lt;/SPAN&gt;(od_PropertyChanged);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;data.Add(cust);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cvs.Source = data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;Handling the PropertyChanged events is to call UpdateObject() method on the DataContext object:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; cust_PropertyChanged(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ctx.UpdateObject(sender &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; ord_PropertyChanged(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ctx.UpdateObject(sender &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; od_PropertyChanged(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ctx.UpdateObject(sender &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;Deleting Data Records&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;To delete records, we need to call the DeleteObject() method on the DataContext object.&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;The following code deletes the current Customer, and all the related Orders and Order_Details, similar to a CASCADE deletion on the database backend: &lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; DeleteItem_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; msg = &lt;SPAN style="COLOR: #a31515"&gt;"Are you sure you want to delete the current customer and all the related order information?"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;HtmlPage&lt;/SPAN&gt;.Window.Confirm(msg))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt; cust = cvs.View.CurrentItem &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt; ord &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; cust.Orders)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt; od &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; ord.Order_Details)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ctx.DeleteObject(od);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ctx.DeleteObject(ord);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ctx.DeleteObject(cust);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.data.Remove(cust);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.bindingNavigator1.RecordCount--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.bindingNavigator1.RefreshControls();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;Similarly, we can delete the current selected Order and its Order_Details using the following code:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; btnDeleteOrder_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; msg = &lt;SPAN style="COLOR: #a31515"&gt;"Are you sure you want to delete the current order and all the order details?"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;HtmlPage&lt;/SPAN&gt;.Window.Confirm(msg))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt; ord = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ordersDataGrid.SelectedItem &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; curOrderID = ord.OrderID;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt; cust &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.data)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (cust.CustomerID == ord.CustomerID)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt; o &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; cust.Orders)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (o.OrderID == curOrderID)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt;&amp;gt; order_DetailsToRemove = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt; od &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; o.Order_Details)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ctx.DeleteObject(od);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;order_DetailsToRemove.Add(od);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt; odToRemove &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; order_DetailsToRemove)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;o.Order_Details.Remove(odToRemove);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ctx.DeleteObject(o);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;cust.Orders.Remove(o);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;And here’s the code to delete the currently selected Order_Details:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; btnDeleteOrder_Detail_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; msg = &lt;SPAN style="COLOR: #a31515"&gt;"Are you sure you want to delete the current order detail?"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;HtmlPage&lt;/SPAN&gt;.Window.Confirm(msg))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt; curOrder_Detail = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.order_DetailsDataGrid.SelectedItem &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ctx.DeleteObject(curOrder_Detail);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt; curOrder = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ordersDataGrid.SelectedItem &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; curOrderID = curOrder.OrderID;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt; cust &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.data)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (cust.CustomerID == curOrder.CustomerID)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt; o &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; cust.Orders)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (o.OrderID == curOrderID)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;o.Order_Details.Remove(curOrder_Detail);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;Adding New Data Records&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;To add new records, we can call the Create&amp;lt;OBJECT&amp;gt; method on the DataContract object, and then call the AddTo&amp;lt;OBJECTS&amp;gt; method of the DataContext object. For example, to add a new Customer, we can use the following:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt"&gt;Customer&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; cust = &lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;.CreateCustomer(&lt;SPAN style="COLOR: #a31515"&gt;"ABCDE"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"ABCDE Corp"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;this&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;.ctx.AddToCustomers(cust);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;By drag-dropping data sources from the Data Sources window, we can easily create new data entry UI as Silverlight controls. This is the new data entry UI I created by stripping data binding XAML from the generated UI:&lt;/P&gt;&lt;/FONT&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Acc.NETDataServiceinaSilverlightApplicat_2A26/NewCustomerDataEntry.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=NewCustomerDataEntry border=0 alt=NewCustomerDataEntry src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Acc.NETDataServiceinaSilverlightApplicat_2A26/NewCustomerDataEntry_thumb.png" width=455 height=386&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SHAPETYPE id=_x0000_t75 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;&lt;STROKE joinstyle="miter"&gt;&lt;/STROKE&gt;&lt;FORMULAS&gt;&lt;F eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/F&gt;&lt;F eqn="sum @0 1 0"&gt;&lt;/F&gt;&lt;F eqn="sum 0 0 @1"&gt;&lt;/F&gt;&lt;F eqn="prod @2 1 2"&gt;&lt;/F&gt;&lt;F eqn="prod @3 21600 pixelWidth"&gt;&lt;/F&gt;&lt;F eqn="prod @3 21600 pixelHeight"&gt;&lt;/F&gt;&lt;F eqn="sum @0 0 1"&gt;&lt;/F&gt;&lt;F eqn="prod @6 1 2"&gt;&lt;/F&gt;&lt;F eqn="prod @7 21600 pixelWidth"&gt;&lt;/F&gt;&lt;F eqn="sum @8 21600 0"&gt;&lt;/F&gt;&lt;F eqn="prod @7 21600 pixelHeight"&gt;&lt;/F&gt;&lt;F eqn="sum @10 21600 0"&gt;&lt;/F&gt;&lt;/FORMULAS&gt;&lt;PATH o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt;&lt;/PATH&gt;&lt;LOCK v:ext="edit" aspectratio="t"&gt;&lt;/LOCK&gt;&lt;/SHAPETYPE&gt;&lt;SHAPE style="WIDTH: 381pt; HEIGHT: 323.25pt; VISIBILITY: visible; mso-wrap-style: square" id=Picture_x0020_1 type="#_x0000_t75" o:spid="_x0000_i1025"&gt;&lt;IMAGEDATA mce_src="file:///C:\Users\xizeng\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" src="file:///C:\Users\xizeng\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" o:title="o:title"&gt;&lt;/IMAGEDATA&gt;&lt;/SHAPE&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;FONT size=3 face=Calibri&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;The Orders table in the database has OrderID as an IDENTITY field (auto-increment), so we can create a new Order object by setting -1 as OrderID:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt"&gt;Order&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; ord = &lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt;.CreateOrder(-&lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt"&gt;Customer&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; cust = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.cvs.View.CurrentItem &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;ord.CustomerID = cust.CustomerID; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: green; FONT-SIZE: 9.5pt"&gt;// Set other properties …&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;cust.Orders.Add(ord);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;this&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;.ctx.AddToOrders(ord);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;Here’s the code to create a new Order_Details:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt"&gt;Order&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; ord = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.ordersDataGrid.SelectedItem &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Order&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; productID = &lt;SPAN style="COLOR: #2b91af"&gt;Int32&lt;/SPAN&gt;.Parse(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.order_DetailsDataEntry.productIDTextBox.Text); &lt;SPAN style="COLOR: green"&gt;//32&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;decimal&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; unitPrice = &lt;SPAN style="COLOR: #2b91af"&gt;Decimal&lt;/SPAN&gt;.Parse(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.order_DetailsDataEntry.unitPriceTextBox.Text); &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;short&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; quantity = &lt;SPAN style="COLOR: blue"&gt;short&lt;/SPAN&gt;.Parse(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.order_DetailsDataEntry.quantityTextBox.Text); &lt;SPAN style="COLOR: green"&gt;//5&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;float&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; discount = &lt;SPAN style="COLOR: blue"&gt;float&lt;/SPAN&gt;.Parse(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.order_DetailsDataEntry.discountTextBox.Text); &lt;SPAN style="COLOR: green"&gt;//0.25f&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt"&gt;Order_Details&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; od = &lt;SPAN style="COLOR: #2b91af"&gt;Order_Details&lt;/SPAN&gt;.CreateOrder_Details(ord.OrderID, productID, unitPrice, quantity, discount);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;ord.Order_Details.Add(od);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;this&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;.ctx.AddToOrder_Details(od);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;Saving Changes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;To save changes, we can simply call the SaveChanges() method on the DataContext object. The code is similar to the following (note you may want add code to handle data update exceptions not done here):&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; SaveItem_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ctx.BeginSaveChanges(System.Data.Services.Client.&lt;SPAN style="COLOR: #2b91af"&gt;SaveChangesOptions&lt;/SPAN&gt;.Batch, &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt;(OnSaveChangesComplete), &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; OnSaveChangesComplete(&lt;SPAN style="COLOR: #2b91af"&gt;IAsyncResult&lt;/SPAN&gt; result)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ctx.EndSaveChanges(result);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;Up to this point, we have developed a Silverlight application capable of loading data through an ADO.NET Data Service, navigating through the data records, performing updating/deleting/inserting &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;operations, and finally committing changes to the database backend. Data validation and error handling during save is not handled here but users can easily hook up their own business logic.&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;Hope you will enjoy developing data applications with Silverlight.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9919036" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/ADO.Net+Data+Services/default.aspx">ADO.Net Data Services</category></item><item><title>Accessing Master-Detail Data through ADO.NET Data Service in a Silverlight Application (Part 1)</title><link>http://blogs.msdn.com/vsdata/archive/2009/10/22/accessing-master-detail-data-through-ado-net-data-service-in-a-silverlight-application-part-1.aspx</link><pubDate>Thu, 22 Oct 2009 18:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9911947</guid><dc:creator>XiangZeng</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9911947.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9911947</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9911947</wfw:comment><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;With Visual Studio 2010 Beta2, users can add data sources to a Silverlight application using the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.100).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;Data Source Configuration Wizard&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;. The added data source is shown in the Data Sources tool window, and can be drag-dropped to Silverlight designer, with data-bound controls automatically generated.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In this post, I’ll walk you through the steps of creating an ADO.NET Data Service to access data using Entity Data Model, and creating a Silverlight application to consume the data service. We’ll build a classic Northwind order management application where users can do CRUD operations on customer and order information through the service.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The completed application will look like this: &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Acc.NETDataServiceinaSilverlightApplicat_129BF/image_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Acc.NETDataServiceinaSilverlightApplicat_129BF/image_thumb.png" width=510 height=237&gt;&lt;/A&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Note&lt;/B&gt;: Although the following walkthrough uses Visual C# as the programming language, you can complete it in VB as well to achieve the same functionalities.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Calibri&gt;Creating an ADO.NET Data Service 
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;FONT size=3 face=Calibri&gt;To create an ADO.NET Data Service, we will need to first create a new ASP.NET Web Application to host the service.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Here are the steps to create the project, define an ADO.NET Entity Data Model, and add ADO.NET Data Service:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Select Visual Studio File-&amp;gt;New Project menu, and choose ASP.NET Web Application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;From Solution Explorer, right click the Web Application project node, and choose Add New Item. In the Add New Item dialog, choose ADO.NET Entity Data Model under the Data category. This will invoke the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb399247(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb399247(VS.100).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;Entity Data Model Wizard&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Follow the Entity Data Model Wizard to connect to a Northwind SQL Server database, and choose tables: Customers, Orders, and Order_Details.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;From Solution Explorer, right click the Web Application project node, and choose Add New Item. In the Add New Item dialog, choose &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc838234(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc838234(VS.95).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;ADO.NET Data Service&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; under the Web category. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-fareast-font-family: consolas"&gt;&lt;SPAN style="mso-list: ignore"&gt;5.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;The WebDataService1.svc.cs (or WebDataService1.svc.vb) file will be opened in VS code editor. We’ll need to modify the code as follows to expose the data model and set appropriate access rules. Note we have changed the default &lt;B style="mso-bidi-font-weight: normal"&gt;EntitySetRights&lt;/B&gt; from &lt;B style="mso-bidi-font-weight: normal"&gt;AllRead&lt;/B&gt; to &lt;B style="mso-bidi-font-weight: normal"&gt;All&lt;/B&gt; so that we are able to update the entities later.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NorthwindWebDataService&lt;/SPAN&gt;&lt;FONT color=#000000&gt; : &lt;/FONT&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataService&lt;/SPAN&gt;&lt;FONT color=#000000&gt;&amp;lt; &lt;/FONT&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NorthwindEntities&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &amp;gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt;&lt;FONT color=#000000&gt; InitializeService(&lt;/FONT&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataServiceConfiguration&lt;/SPAN&gt;&lt;FONT color=#000000&gt; config)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;config.SetEntitySetAccessRule(&lt;/FONT&gt;&lt;SPAN style="COLOR: #a31515"&gt;"*"&lt;/SPAN&gt;&lt;FONT color=#000000&gt;, &lt;/FONT&gt;&lt;SPAN style="COLOR: #2b91af"&gt;EntitySetRights&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.All);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;config.SetServiceOperationAccessRule(&lt;/FONT&gt;&lt;SPAN style="COLOR: #a31515"&gt;"*"&lt;/SPAN&gt;&lt;FONT color=#000000&gt;, &lt;/FONT&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ServiceOperationRights&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.All);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;config.DataServiceBehavior.MaxProtocolVersion = &lt;/FONT&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataServiceProtocolVersion&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.V2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;6.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Build the project. &lt;/FONT&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;At this point, our Data Service is ready to be consumed by client applications.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Calibri&gt;Creating a Silverlight Application to Consume the ADO.NET Data Service 
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;FONT size=3 face=Calibri&gt;Now let’s create a Silverlight Application to consume the data service. The following steps create a Silverlight application, and add a new data source to consume the above ADO.NET Data Service:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo2" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;From Visual Studio File-&amp;gt;Add New Project menu, choose Silverlight Application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo2" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;On the New Silverlight Application dialog, accept the default to host the Silverlight Application in the above ASP.NET Web Application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo2" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;From Visual Studio Data menu, choose Add New Data Source.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo2" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;On the Data Source Configuration Wizard, choose Service as the data source type, and click Next.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo2" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;5.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;This will bring up the Add Service Reference dialog. Since our data service is in the same solution, we can click the Discover button to find the above ADO.NET Data Service, or type in the service address (like &lt;/FONT&gt;&lt;A href="http://localhost:%3cPORT%20NUMBER%3e/WebDataService1.svc" mce_href="http://localhost:%3cPORT%20NUMBER%3e/WebDataService1.svc"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;http://localhost:&amp;lt;PORT NUMBER&amp;gt;/WebDataService1.svc&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;), and click OK.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l1 level1 lfo2" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;6.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Finish the Data Source Configuration Wizard. A new Service Reference will be added in Solution Explorer, with a code file containing data classes used to access and interact with data service resources as objects.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Calibri&gt;Drag-dropping Data Sources onto Silverlight Designer 
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;FONT size=3 face=Calibri&gt;In the above steps, we have added a Service data source to the Silverlight application. If you open the Data Sources tool window, the data objects accessible through the ADO.NET Data Service should be shown and available for drag-dropping to the Silverlight designer. However, due to a bug not yet fixed, you may need to close VS and then reopen it (this bug applies only to data services created within the same solution. If you have an existing data service, the Data Sources window will show the data objects immediately).&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo3" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;From Visual Studio Data menu, choose Show Data Sources. The Data Sources tool window will show up with data objects from the ADO.NET Data Service:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Customers, Orders, and Order_Details.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo3" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3 face=Calibri&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;In the Northwind Order Manager application, we want to show the customer information as details rather than the default DataGrid. To do this, in the Data Sources window, drop-down the Customers ComboBox, and choose Details. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo3; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-fareast-font-family: consolas"&gt;&lt;SPAN style="mso-list: ignore"&gt;3.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Now drag Customers node to MainPage.xaml designer. The customer information is generated on the designer as data-bound controls. The XAML code also contains data binding information similar to the following: &lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;CollectionViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="customersViewSource"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; d&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt;DesignSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;d&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;DesignInstance&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; my&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt;Customer&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; CreateList&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;=True}" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo3; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt; mso-fareast-font-family: consolas"&gt;&lt;SPAN style="mso-list: ignore"&gt;4.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;To show the related Orders and Order_Details information, drag Customers.Orders (&lt;B style="mso-bidi-font-weight: normal"&gt;IMPORTANT&lt;/B&gt;: this is the child node Orders, under Customers node) and Customers.Orders.Order_Details from Data Sources Window to MainPage.xaml designer. The generated CollectionViewSource nodes in the XAML file will be similar to the following: &lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;CollectionViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="customersOrdersViewSource"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Path&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;=Orders,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;={&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; customersViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;}}" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;CollectionViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="customersOrdersOrder_DetailsViewSource"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Path&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;=Order_Details,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;={&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; customersOrdersViewSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;}}" /&amp;gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Calibri&gt;Writing Code to Load Data at Run Time 
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;FONT size=3 face=Calibri&gt;We’ll need to write some code to load the data at run time. Let’s declare some private members in the MainPage class in MainPage.xaml.cs:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;NorthwindEntities&lt;/SPAN&gt; ctx; // The data context &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;CollectionViewSource&lt;/SPAN&gt; cvs; // The CollectionViewSource to bind data&amp;nbsp;&lt;/SPAN&gt; 
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataServiceQuery&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&amp;gt; qry; // The query to load data &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; System.Collections.ObjectModel.&lt;SPAN style="COLOR: #2b91af"&gt;ObservableCollection&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&amp;gt; data = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; System.Collections.ObjectModel.&lt;SPAN style="COLOR: #2b91af"&gt;ObservableCollection&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&amp;gt;(); &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In the MainPage.xaml.cs LayoutRoot_Loaded event handler, add the following code to instantiate the data service, define a DataServiceQuery and execute it to retrieve data. The retrieval of data is done through an asynchronous call.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; LayoutRoot_Loaded(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ctx = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;NorthwindEntities&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"http://localhost:&amp;lt;PORT NUMBER&amp;gt;/NorthwindWebDataService.svc"&lt;/SPAN&gt;)); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cvs = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.Resources[&lt;SPAN style="COLOR: #a31515"&gt;"customersViewSource"&lt;/SPAN&gt;] &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;CollectionViewSource&lt;/SPAN&gt;; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;qry = ctx.Customers.Expand(&lt;SPAN style="COLOR: #a31515"&gt;"Orders"&lt;/SPAN&gt;).Expand(&lt;SPAN style="COLOR: #a31515"&gt;"Orders/Order_Details"&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;qry.BeginExecute(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt;(OnDataLoadComplete), &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; OnDataLoadComplete(&lt;SPAN style="COLOR: #2b91af"&gt;IAsyncResult&lt;/SPAN&gt; result) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&amp;gt; custs = qry.EndExecute(result).ToList(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt; cust &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; custs) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;data.Add(cust); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} 
&lt;P mce_keep="true"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cvs.Source = data;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Note we are using an ObservableCollection&amp;lt;T&amp;gt; to be the Source of the CollectionViewSource, rather than just a List&amp;lt;T&amp;gt; or DataServiceQuery&amp;lt;T&amp;gt; . This is so that we can get notifications when data get added, updated or removed since we are going to update and save data later.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you do not need to update data, you may just need to set the CollectionViewSource.Source to the DataServiceQuery like :&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;cvs.Source = ctx.Customers.Expand(&lt;SPAN style="COLOR: #a31515"&gt;"Orders"&lt;/SPAN&gt;).Expand(&lt;SPAN style="COLOR: #a31515"&gt;"Orders/Order_Details"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Calibri&gt;Navigating through Data 
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;FONT size=3 face=Calibri&gt;To add the functionality of navigating through data at run time, we can create a Silverlight User Control similar to the following:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Acc.NETDataServiceinaSilverlightApplicat_129BF/image_4.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Acc.NETDataServiceinaSilverlightApplicat_129BF/image_thumb_1.png" width=285 height=37&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;SHAPE style="WIDTH: 252.75pt; HEIGHT: 29.25pt; VISIBILITY: visible; mso-wrap-style: square" id=Picture_x0020_1 o:spid="_x0000_i1025" type="#_x0000_t75"&gt;&lt;IMAGEDATA o:title="o:title" src="file:///C:\Users\xizeng\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png" mce_src="file:///C:\Users\xizeng\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png"&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/IMAGEDATA&gt;&lt;/SHAPE&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The XAML for one of the buttons is similar to this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Margin&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="5"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; IsEnabled&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="False"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="moveFirstItem"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Click&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="moveFirstItem_Click"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Image&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="23"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="moveFirstItemImage"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; Source&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="BindingNavigator_Icons/MoveFirstItem.ico"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Image.OpacityMask&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;ImageBrush&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;ImageBrush.ImageSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;BitmapImage&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: red; FONT-SIZE: 9.5pt"&gt; UriSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="BindingNavigator_Icons/MoveFirstItem.ico" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;ImageBrush.ImageSource&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;ImageBrush&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Image.OpacityMask&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Image&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;To move to the beginning of the data collection, we can handle the MoveFirstItem button Click event with the following code:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; moveFirstItem_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cvs.View.MoveCurrentToFirst(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RefreshControls(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;} &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The RefreshControls() method handles the logic to update the current position display and enable or disable buttons based on the current record position:&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt; &lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; RefreshControls() &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; pos = cvs.View.CurrentPosition; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.positionItem.Text = (pos + &lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;).ToString(System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo&lt;/SPAN&gt;.CurrentCulture); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.countItem.Text = &lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt;.Format(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.countItemTemplate, &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.recordCount); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.moveFirstItem.IsEnabled = (pos &amp;gt; &lt;SPAN style="COLOR: brown"&gt;0&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.movePreviousItem.IsEnabled = (pos &amp;gt; &lt;SPAN style="COLOR: brown"&gt;0&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.moveNextItem.IsEnabled = (pos &amp;lt; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.RecordCount - &lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.moveLastItem.IsEnabled = (pos &amp;lt; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.RecordCount - &lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.deleteItem.IsEnabled = (&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.RecordCount &amp;gt; &lt;SPAN style="COLOR: brown"&gt;0&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;} &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Similarly, we can use the following code to navigate through the records by moving back and forth:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; movePreviousItem_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cvs.View.MoveCurrentToPrevious(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RefreshControls(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;} 
&lt;P mce_keep="true"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; moveNextItem_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;{&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cvs.View.MoveCurrentToNext();&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RefreshControls(); &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;} &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; moveLastItem_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;{&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cvs.View.MoveCurrentToLast();&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RefreshControls(); &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;} &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;We also provide the functionality to navigate to a specific position using the TextBox to accept user input, and navigate when the user presses the ENTER key with a valid position entered. If the number entered is not valid, it will just be ignored and the record stays at the current position. If the number is smaller than 1, we navigate to the first record instead. If the number entered is greater than the record count, we navigate to the last record. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; positionItem_KeyDown(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;KeyEventArgs&lt;/SPAN&gt; e) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (e.Key == &lt;SPAN style="COLOR: #2b91af"&gt;Key&lt;/SPAN&gt;.Enter)&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;TextBox&lt;/SPAN&gt; txt = sender &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;TextBox&lt;/SPAN&gt;; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; curPos = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.cvs.View.CurrentPosition + &lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; pos; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isValid = &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;.TryParse(txt.Text, &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; pos); &lt;BR&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (!isValid) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;txt.Text = curPos.ToString(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (pos &amp;lt;= &lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pos = &lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (pos &amp;gt; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.recordCount) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pos = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.recordCount; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;BR&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (curPos != pos) &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.cvs.View.MoveCurrentToPosition(pos - &lt;SPAN style="COLOR: brown"&gt;1&lt;/SPAN&gt;); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;BR&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;txt.Text = pos.ToString(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RefreshControls(); &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: consolas; FONT-SIZE: 9.5pt"&gt;} 
&lt;P mce_keep="true"&gt;&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 14pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Calibri&gt;Next Steps &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;FONT size=3 face=Calibri&gt;The next part of this post will add functionalities to update and save Customers, Orders and Order_Details. We will also develop the application to be able to delete data and add new records.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911947" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/ADO.Net+Data+Services/default.aspx">ADO.Net Data Services</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Source+Wizard/default.aspx">Data Source Wizard</category></item><item><title>Entity Data Model: working with foreign key when you don’t have it</title><link>http://blogs.msdn.com/vsdata/archive/2009/10/16/entity-data-model-working-with-foreign-key-when-you-don-t-have-it.aspx</link><pubDate>Thu, 15 Oct 2009 23:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9908576</guid><dc:creator>Yang Cao</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9908576.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9908576</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9908576</wfw:comment><description>&lt;P&gt;It’s been debatable whether to include FK (foreign key) columns in the conceptual model. That’s why in Visual Studio 2010, a checkbox is added to Entity Data Model Wizard, so that the decision is left to the developers. While I was playing with it yesterday, I found FK particularly useful in the following scenario.&lt;/P&gt;
&lt;P&gt;The application I was trying to build is really simple: change an order’s related customer from A to B. &lt;BR&gt;&lt;A href="file:///C:/Users/YANGCAO/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles15B73D/image[4].png" mce_href="file:///C:\Users\YANGCAO\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles15B73D\image%5b4%5d.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image001 border=0 alt=clip_image001 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/EntityDataModelworkingwithforeignkeywhen_9ED7/clip_image001_991716bb-394b-4cb3-982a-7bdac4547373.png" width=494 height=333 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/EntityDataModelworkingwithforeignkeywhen_9ED7/clip_image001_991716bb-394b-4cb3-982a-7bdac4547373.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If FK (CustomerID) is in my Order entity, I could just do a lookup binding to this FK column, and call dataContext.SaveChanges().The drag-n-drop way of doing lookup binding to a ComboBox is to first drag the FK property (in this example, CustomerID in Order entity) with a ComboBox control, and drop it onto the form. Then drag the related lookup table (Customer entity) and drop it onto the previously created ComboBox control. The SelectedValue, SelectedValuePath, ItemsSource, and DisplayMemeberPath properties will be set for you.&lt;/P&gt;
&lt;P&gt;Things become a little bit tricky if I don’t have the FK in the entity.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Data bind Orders to a DataGrid&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This step is fairly easy. Just drag Orders node onto the WPF Designer. &lt;BR&gt;&lt;A href="file:///C:/Users/YANGCAO/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles15B73D/image[8].png" mce_href="file:///C:\Users\YANGCAO\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles15B73D\image%5b8%5d.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image002 border=0 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/EntityDataModelworkingwithforeignkeywhen_9ED7/clip_image002_cb4ca5e9-be96-406a-be0d-26b6a5c1bb92.png" width=200 height=378 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/EntityDataModelworkingwithforeignkeywhen_9ED7/clip_image002_cb4ca5e9-be96-406a-be0d-26b6a5c1bb92.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Create lookup binding to a ComboBox&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Because I don’t have the FK column in the model, there’s no CustomerID property in Order entity. To create the lookup binding, I need to expand the navigation property Customer in Orders, and bind the CustomerID to a combobox. &lt;BR&gt;&lt;A href="file:///C:/Users/YANGCAO/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles15B73D/image[16].png" mce_href="file:///C:\Users\YANGCAO\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles15B73D\image%5b16%5d.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image003 border=0 alt=clip_image003 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/EntityDataModelworkingwithforeignkeywhen_9ED7/clip_image003_0eb485d1-7221-4c91-ae0f-9cf440176689.png" width=202 height=585 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/EntityDataModelworkingwithforeignkeywhen_9ED7/clip_image003_0eb485d1-7221-4c91-ae0f-9cf440176689.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;After I drag-n-drop this node onto WPF Designer, I will have created a complex binding. To make it a lookup binding, I will link the newly created combobox to the lookup table. The way to do it is to drag the Customers node (marked with 2 on the picture above), and drop it onto the combobox. Please notice that while doing this, your cursor will change from a little + to an arrow, to indicate that we will not generate a new control. Instead, an existing control will be updated with the dragged data source.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Create button to save changes &lt;BR&gt;&lt;/B&gt;Then I will &lt;A&gt;a&lt;/A&gt;dd a button to “Update Customer”. In the click event handler, I need to find current selected order, get the new CustomerID that replace the old FK value, and save the changes:&lt;/P&gt;
&lt;P&gt;Order currentOrder = (Order)ordersViewSource.View.CurrentItem;&lt;/P&gt;
&lt;P&gt;string customerID = customerIDComboBox.SelectedValue.ToString();&lt;/P&gt;
&lt;P&gt;currentOrder.CustomerReference.EntityKey.EntityKeyValues[0].Value = customerID;&lt;/P&gt;
&lt;P&gt;northwindEntities.SaveChanges();&lt;/P&gt;
&lt;P&gt;I made the data context (northwindEntities) and colletion view source (ordersViewSource) to be the property in MainWindow class, to make the code simple. I need to drill down into the order, find the CustomerReference, and set the EntityKeyValue.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;F5&lt;/B&gt; &lt;BR&gt;Debug the application now. Everything looks good at first, but when I change the customer from one to another in the drop-down combobox, Bang! I get an InvalidOperationException: The property 'CustomerID' is part of the object's key information and cannot be modified. Although I successfully created the lookup binding, I cannot modify the value because the SelectedValue is not the FK in Order, but the PK in Customer!&lt;/P&gt;
&lt;P&gt;This tells me that the combobox should be bound OneWay. I locate the combobox in XAML, and updated the SelectedValue binding mode:&lt;/P&gt;
&lt;P&gt;SelectedValue="{Binding Path=Customer.CustomerID,Mode=OneWay}"&lt;/P&gt;
&lt;P&gt;&lt;B&gt;F5 again&lt;/B&gt; &lt;BR&gt;Now change selection in the combobox will not trigger the exception anymore. I click on the “Update Customer” button to continue testing, bang (again)! This time, it says EntityKey values cannot be changed once they are set. I don’t believe there’s no way to do it, so I searched around the web and found that although the value cannot be reset, the entity key can be. Now let’s assign the FK value in this way:&lt;/P&gt;
&lt;P&gt;currentOrder.CustomerReference.EntityKey = new System.Data.EntityKey(&lt;/P&gt;
&lt;P&gt;currentOrder.CustomerReference.EntityKey.EntityContainerName+"."+currentOrder.CustomerReference.EntityKey.EntitySetName,&lt;/P&gt;
&lt;P&gt;"CustomerID", customerID);&lt;/P&gt;
&lt;P&gt;You could also use KeyValuePair if you have a complex key composed of more than one property. For more information, please see &lt;A href="http://msdn.microsoft.com/en-us/library/system.data.entitykey.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.data.entitykey.aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;After all the steps above, my application finally works as I expected. You might ask, why don’t you just include the key to save all these coding and bang (runtime exception)? Some developers, as I said, vote for not including FK in the conceptual model because FK is a relational database concept and it will pollute the object world. Another reason is, the feature of include FK is only available in Visual Studio 2010, targeting .NET framework 4.0, for newly added tables. If you have an existing entity data model, you would still need to get yourself used to the life without FK.&lt;/P&gt;
&lt;P&gt;Please let me know if you have any other idea or question about this!&lt;/P&gt;
&lt;P&gt;Cheers!&lt;/P&gt;
&lt;P&gt;[Update 10/20]: Alex has a post talking about this too. He suggested a way of wrapping the entity key so that a FK property is added into the partial class. Please check it out here: &lt;A href="http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx"&gt;http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9908576" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>Refresh the Primary Key Identity Column during Insert Operation</title><link>http://blogs.msdn.com/vsdata/archive/2009/09/14/refresh-the-primary-key-identity-column-during-insert-operation.aspx</link><pubDate>Tue, 15 Sep 2009 08:17:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895249</guid><dc:creator>John Chen</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9895249.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9895249</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9895249</wfw:comment><description>&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;If you have an identity primary key column defined in a database table, its value will be automatically set by the database engine when you insert a new row to the table. The identity value is determined by the column’s Identity Seed and Identity Increment properties.        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;While in your client application, you can insert a new row into a corresponding ADO.NET DataTable (DataTable can be seen as the in memory cache of the data table in the database, I will use DataTable as the example in this post). You will not get the true value until you commit the update to the database. What you see before the update is not what you get after the update. For better user experience, you really want to refresh the database to retrieve the correct identity value back right after the insert operation.        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;In this post, I will describe the way to retrieve the identity value in ADO.NET applications with the help of Visual Studio Database Tools. I will start with a sample Windows Forms application using DataSet. My database server is SQL Server.        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;First in Visual Studio (2005 and after) server explorer, I establish a data connection connects to a SQL Server database.&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;I create a data table in the database called MyCustomer with three columns: CustId, Name and Company. CustId is defined as primary key and an identity column. Identity Seed and Identity Increment are set as 1 by default as shown in Figure 1 below. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;       &lt;p&gt;&lt;img title="Figure 1" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="303" alt="Figure 1" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%201_thumb.jpg" width="561" border="0" /&gt; &lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"&gt;&lt;stroke joinstyle="miter"&gt;&lt;/stroke&gt;&lt;formulas&gt;&lt;f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/f&gt;&lt;f eqn="sum @0 1 0"&gt;&lt;/f&gt;&lt;f eqn="sum 0 0 @1"&gt;&lt;/f&gt;&lt;f eqn="prod @2 1 2"&gt;&lt;/f&gt;&lt;f eqn="prod @3 21600 pixelWidth"&gt;&lt;/f&gt;&lt;f eqn="prod @3 21600 pixelHeight"&gt;&lt;/f&gt;&lt;f eqn="sum @0 0 1"&gt;&lt;/f&gt;&lt;f eqn="prod @6 1 2"&gt;&lt;/f&gt;&lt;f eqn="prod @7 21600 pixelWidth"&gt;&lt;/f&gt;&lt;f eqn="sum @8 21600 0"&gt;&lt;/f&gt;&lt;f eqn="prod @7 21600 pixelHeight"&gt;&lt;/f&gt;&lt;f eqn="sum @10 21600 0"&gt;&lt;/f&gt;&lt;/formulas&gt;&lt;path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt;&lt;/path&gt;&lt;lock aspectratio="t" v:ext="edit"&gt;&lt;/lock&gt;&lt;/shapetype&gt;&lt;shape id="Picture_x0020_0" style="visibility: visible; width: 468pt; height: 250.5pt; mso-wrap-style: square" alt="Figure 1.JPG" type="#_x0000_t75" o:spid="_x0000_i1030"&gt;&lt;imagedata o:title="Figure 1" src="file:///C:\Users\johnchen\AppData\Local\Temp\msohtmlclip1\01\clip_image001.jpg"&gt;&lt;/imagedata&gt;&lt;/shape&gt;&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Figure 1 MyCustomer table defined in database         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0pt"&gt;&lt;span style="font-size: 11pt; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;Then I create my DataSet through the &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.100).aspx"&gt;&lt;span style="font-size: 11pt; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;font color="#800080"&gt;Data Source Configuration Wizard&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: 11pt; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, or by adding a DataSet and then dragging and dropping MyCustomer from Server Explorer to the DataSet Designer. By opening the DataSet and selecting the CustId column, you will see that it has the following properties:&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;AutoIncrement=True, and AutoIncrementSeed = -1 , AutoIncrementStep = -1 (Figure 2).&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;These properties are used by ADO.NET to auto generate the CustId’s placeholder values for newly added rows.&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0pt"&gt;&lt;span style="font-size: 11pt; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0pt"&gt;&lt;span style="font-size: 11pt; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;b&gt;&lt;span style="color: black"&gt;         &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%202.jpg"&gt;&lt;img title="Figure 2" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="298" alt="Figure 2" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%202_thumb.jpg" width="565" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;shape id="Picture_x0020_1" style="visibility: visible; width: 468pt; height: 245.25pt; mso-wrap-style: square" alt="Figure 2.JPG" type="#_x0000_t75" o:spid="_x0000_i1029"&gt;&lt;imagedata o:title="Figure 2" src="file:///C:\Users\johnchen\AppData\Local\Temp\msohtmlclip1\01\clip_image003.jpg"&gt;&lt;/imagedata&gt;&lt;/shape&gt;&lt;/span&gt;    &lt;p&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Figure 2. CustId properties in the DataTable         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;The AutoIncrement property corresponds to the Identity property in the database. AutoIncrementSeed corresponds to Identity Seed, and AutoIncrementStep to Identity Increment. You may be curious why both AutoIncrementSeed and AutoIncrementStep are set to -1. T&lt;span style="color: black; mso-bidi-font-family: arial"&gt;his is an approach to ensure that the placeholder values that ADO.NET generates will not conflict with values that already exist in the database. Another benefit is it looks like unreal so users will know that it is just a temporary placeholder value.          &lt;p&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;span style="color: black; mso-bidi-font-family: arial"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Now if you click on the MyCustomerTableAdapter header and show its CommandText for Insert Command, you will see this:          &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;; mso-bidi-theme-font: minor-bidi"&gt;   &lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;; mso-bidi-theme-font: minor-bidi"&gt;&lt;font size="2"&gt;INSERT INTO [MyCustomer] ([Name], [Company]) VALUES (@Name, @Company);         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;; mso-bidi-theme-font: minor-bidi"&gt;&lt;font size="2"&gt;SELECT CustId, Name, Company FROM MyCustomer WHERE (CustId = SCOPE_IDENTITY())&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;; mso-bidi-theme-font: minor-bidi"&gt;&lt;font size="3"&gt;         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNoSpacing" style="background: #bfbfbf; margin: 0in 0in 0pt; mso-background-themecolor: background1; mso-background-themeshade: 191"&gt;&lt;/p&gt;   &lt;font face="Calibri" size="3"&gt;The command text contains two statements and the second one is used to retrieve the primary key value after the insert operation is committed. Notice the use of the SCOPE_IDENTITY function, which is defined so in &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms190315.aspx"&gt;&lt;font face="Calibri" color="#800080" size="3"&gt;MSDN&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;:        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;  &lt;p class="MsoQuote" style="margin: 0in 0in 10pt"&gt;&lt;em&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;“&lt;b style="mso-bidi-font-weight: normal"&gt;SCOPE_IDENTITY (Transact-SQL)&lt;/b&gt; Returns the last identity value inserted into an identity column in the same scope. A scope is a module: a stored procedure, trigger, function, or batch. Therefore, two statements are in the same scope if they are in the same stored procedure, function, or batch”          &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0pt"&gt;&lt;font face="Times New Roman" size="3"&gt;The auto generation of the second statement in Insert command is controlled by the “refresh data table option” in the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dex7k4dw(VS.100).aspx"&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;font color="#800080" size="3"&gt;TableAdapter Configuration Wizard&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;font size="3"&gt;&lt;font face="Times New Roman"&gt; (Figure 3). &lt;b&gt;&lt;span style="font-size: 11pt; color: black; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;           &lt;p&gt;&lt;/p&gt;         &lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;   &lt;p&gt;&lt;font face="Calibri" size="3"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;shape id="Picture_x0020_2" style="visibility: visible; width: 468pt; height: 357pt; mso-wrap-style: square" alt="Figure 3.JPG" type="#_x0000_t75" o:spid="_x0000_i1028"&gt;&lt;imagedata o:title="Figure 3" src="file:///C:\Users\johnchen\AppData\Local\Temp\msohtmlclip1\01\clip_image005.jpg"&gt;&lt;/imagedata&gt;&lt;/shape&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%203.jpg"&gt;&lt;img title="Figure 3" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="379" alt="Figure 3" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%203_thumb.jpg" width="496" border="0" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Figure 3. Refresh the data table advanced option in the TableAdapter Configuration Wizard         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;   &lt;p&gt;&lt;font face="Calibri" size="3"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Now let’s take a look what is the experience when applying this refresh data table feature at run time. Let me open the Form and then show the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/6ckyxa83(VS.100).aspx"&gt;&lt;font face="Calibri" color="#0000ff" size="3"&gt;Data Sources Window&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;. From the Data Sources Window, I drag and drop the MyCustomer table to the Form and I get the following layout (Figure 4): &lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;span style="mso-no-proof: yes"&gt;&lt;shape id="Picture_x0020_3" style="visibility: visible; width: 468pt; height: 258.75pt; mso-wrap-style: square" alt="Figure 4.JPG" type="#_x0000_t75" o:spid="_x0000_i1027"&gt;&lt;imagedata o:title="Figure 4" src="file:///C:\Users\johnchen\AppData\Local\Temp\msohtmlclip1\01\clip_image007.jpg"&gt;&lt;/imagedata&gt;&lt;/shape&gt;&lt;/span&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%204.jpg"&gt;&lt;img title="Figure 4" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="307" alt="Figure 4" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%204_thumb.jpg" width="551" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/i&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;Figure 4. At design time: Drag and Drop MyCustomer from the Data Sources window to the form&lt;/i&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;   &lt;p&gt;&lt;font face="Calibri" size="3"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Hit F5 to run the app. Click on the Add New (the + sign) button to add some rows. Notice that I will get values of -1, -2, -3, etc. for CustId column.&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;shape id="Picture_x0020_4" style="visibility: visible; width: 315pt; height: 250.5pt; mso-wrap-style: square" alt="Figure 5.JPG" type="#_x0000_t75" o:spid="_x0000_i1026"&gt;&lt;imagedata o:title="Figure 5" src="file:///C:\Users\johnchen\AppData\Local\Temp\msohtmlclip1\01\clip_image009.jpg"&gt;&lt;/imagedata&gt;&lt;/shape&gt;&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%205.jpg"&gt;&lt;img title="Figure 5" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="303" alt="Figure 5" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%205_thumb.jpg" width="380" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Figure 5. CustForm at run time, before committing         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Now I click the Save (the disk sign) button and I see that the CustIds are updated to 9,10,11. Oh! I would expect to get 2,3,4; someone may beat me and add some rows before me. You see that using -1,-2,-3 really make sense here to clearly indicate that the values are not committed.        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;shape id="Picture_x0020_5" style="visibility: visible; width: 312pt; height: 246.75pt; mso-wrap-style: square" alt="Figure 6.JPG" type="#_x0000_t75" o:spid="_x0000_i1025"&gt;&lt;imagedata o:title="Figure 6" src="file:///C:\Users\johnchen\AppData\Local\Temp\msohtmlclip1\01\clip_image010.jpg"&gt;&lt;/imagedata&gt;&lt;/shape&gt;&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%206.jpg"&gt;&lt;img title="Figure 6" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="304" alt="Figure 6" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/RefreshthePrimaryKeyIdentityColumnduring_13977/Figure%206_thumb.jpg" width="383" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Figure 6. CustForm at run time, after committing         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;   &lt;p&gt;&lt;font face="Calibri" size="3"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Now if you are using MS Access database or SQL CE, you will see that the above walk through does not work as expected. When you click the save, the primary key -1,-2,-3 keep unchanged. If you check on the TableAdapter Configuration Wizard, the Refresh the data table option is disabled. If you check the generated insert command, there is only one statement. This is because MS Access database and SQL CE do not support batching SQL statements and therefore cannot use the SCOPE_IDENTITY function. The build-in refresh the data table option is not available for these databases.        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font face="Calibri" size="3"&gt;The good news is there is a sound workaround to fix this by reset the primary key identity value on Adapter.RowUpdated event. &lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;Please see Beth Massi’s blog: &lt;/font&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/05/14/using-tableadapters-to-insert-related-data-into-an-ms-access-database.aspx"&gt;&lt;font face="Calibri" color="#800080" size="3"&gt;Using TableAdapters to Insert Related Data into an MS Access Database&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;. Beth promised to write a follow up post for SQL CE as well. &lt;/font&gt;&lt;span style="font-family: wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-char-type: symbol; mso-symbol-font-family: wingdings"&gt;&lt;span style="mso-char-type: symbol; mso-symbol-font-family: wingdings"&gt;J&lt;/span&gt;&lt;/span&gt;      &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;In summary, SQL server or any database supporting batching operation has a reliable way to retrieve the identity value through the usage of the SCOPE_IDENTITY function. Visual Studio Data Tool provides the auto generated Insert command that leverages this support with the “Refresh the data table” option turn on by default. For databases that do not support batching of SQL statements, resetting the primary key value on row updated event is a good workaround. &lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9895249" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/Typed+Dataset/default.aspx">Typed Dataset</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/SQL+Server+Compact/default.aspx">SQL Server Compact</category></item><item><title>DataRepeater Control for Windows Forms</title><link>http://blogs.msdn.com/vsdata/archive/2009/08/12/datarepeater-control-for-windows-forms.aspx</link><pubDate>Wed, 12 Aug 2009 23:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9867141</guid><dc:creator>John Chen</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9867141.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9867141</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9867141</wfw:comment><description>&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="http://msdn.microsoft.com/en-us/library/cc488279.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc488279.aspx"&gt;DataRepeater control&lt;/A&gt; is available in the &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.aspx"&gt;Visual Basic Power Packs&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;As Yun Feng introduced in his &lt;A href="http://blogs.msdn.com/vsdata/archive/2009/07/24/visual-basic-power-packs-is-included-in-visual-studio-2008-sp1.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/07/24/visual-basic-power-packs-is-included-in-visual-studio-2008-sp1.aspx"&gt;post&lt;/A&gt;, the Visual Basic Power Packs is included in &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en"&gt;Visual Studio 2008 Service Pack 1&lt;/A&gt; and will also be shipped in &lt;A href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" mce_href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx"&gt;Visual Studio 2010&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;The DataRepeater control is my favorite component in the Visual Basic Power Packs, which I proudly participated in from start to finish. Recently I monitored the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/threads" mce_href="http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/threads"&gt;Visual Basic Power Packs forum&lt;/A&gt; and I found that customers are saying nice things about the DataRepeater control as well. A lot of good questions have been asked in the forum. For example, how to print all the data in the DataRepeater, how to display unbound data, how to host a data bound ComboBox in the DataRepeater, etc… I feel motivated to write some posts to answer these non-obvious questions. &lt;/P&gt;
&lt;P&gt;In this post, I will first present the unique features of the DataRepeater control from my perspective. Then I will show a simple walk through for using a DataRepeater control in a data binding application. At the end, I will list the resources available for reference.&lt;/P&gt;
&lt;P&gt;First of all, I would like to point out that the DataRepeater control is a true .Net Windows Forms control. It can be used not only by Visual Basic but also for any other .Net language (e.g. C#). You may be curious why it is under the Visual Basic Power Packs “brand”. The project was initially designed to help VB6 customers migrating to the .Net world with familiar experience and environment. We started the project with the Visual Basic customers in mind as there was already a &lt;A href="http://msdn.microsoft.com/en-us/library/aa239070(VS.60).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa239070(VS.60).aspx"&gt;Data Repeater Control in Visual Basic 6&lt;/A&gt; and unfortunately there was no corresponding control in Visual Studio.Net 2002 to 2008. After we created the control we realized that it would be good for all .NET customers and we decided to make it available to all of Visual Studio.&lt;/P&gt;
&lt;P&gt;To differentiate the DataRepeater controls in VB6 and the one now in Visual Studio 2008 SP1, in this article I would call them &lt;A href="http://msdn.microsoft.com/en-us/library/aa239070(VS.60).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa239070(VS.60).aspx"&gt;VB6 DataRepeater&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/cc488279.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc488279.aspx"&gt;PowerPacks DataRepeater&lt;/A&gt; (or simply DataRepeater). The PowerPacks DataRepeater inherits the basic concept of the VB6 DataRepeater control to display repeated data in a scrollable container. Even more, the PowerPacks DataRepeater has significant improvements over the VB6 DataRepeater. The PowerPacks DataRepeater is modern (as I said, it is a .Net control can be used by all languages), more powerful, has more functions, and yet easier to use taking all the advantages of the .Net and Visual Studio Data Access tools and technologies. &lt;/P&gt;
&lt;P&gt;For example, in VB6, you need to create an intermediate user control to host the VB6 DataRepeater and set up the data binding there, build it and then include the user control in the host form. With PowerPacks DataRepeater, the intermediate user control is no longer needed! You can now drag and drop the DataRepeater control onto the hosting form directly, and then drag and drop controls on its &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.itemtemplate.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.itemtemplate.aspx"&gt;item template&lt;/A&gt; section. You will enjoy a truly &lt;A href="http://en.wikipedia.org/wiki/Wysiwyg" mce_href="http://en.wikipedia.org/wiki/Wysiwyg"&gt;WYSIWYG&lt;/A&gt; design experience.&lt;/P&gt;
&lt;P&gt;Although both DataRepeater controls can host free style controls in the item template section, the PowerPacks DataRepeater allows you to have even more controls on the layout and the appearance of the repeating items. You can use the &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.drawitem.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.drawitem.aspx"&gt;DrawItem&lt;/A&gt; event to customize the color or other appearances as you wish. The &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.layoutstyle.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.layoutstyle.aspx"&gt;LayoutStyle&lt;/A&gt; property lets you specify orientation (vertical or horizontal) of the displayed items. The orientation feature is really attractive and I have seen some customers choose the DataRepeater over the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview(VS.80).aspx"&gt;DataGridView&lt;/A&gt; simply because the DataRepeter can show data in horizontal orientation. &lt;/P&gt;
&lt;P&gt;Talking about the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview(VS.80).aspx"&gt;DataGridView&lt;/A&gt;, the PowerPacks DataRepeater control can be seen as an alternative control to the DataGridView. The PowerPacks DataRepeater follows the design of the DataGridView and you can find many properties (e.g. the &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.virtualmode.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.virtualmode.aspx"&gt;Virtual Mode&lt;/A&gt; property) in DataRepeater control in parity with the DataGridView. This description from MSDN document best describes the role of the PowerPacks DataRepeater -- “It can be used as an alternative to the DataGridView control when you need more control over the layout of the data.”&lt;/P&gt;
&lt;P&gt;The PowerPacks DataRepeater control applies a virtualization technique to display the data in a fashion that scrolling and navigation is fast while rich UI and visual effects are still retained. For example, all displayed controls on the display surface are real controls and you can interact with them without delay. Scrolling is smoothly simulated while VB6 DataRepeater does not have a scroll effect.&lt;/P&gt;
&lt;P&gt;You can further improve performance by turning on the Virtual Mode when you want to display large quantities of tabular data in a PowerPacks &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.aspx"&gt;DataRepeater&lt;/A&gt; control. The Virtual Mode allows you explicitly manage the control’s interaction with its data source. Therefore you can load the data rows only when necessary to reduce the initial loading time. You can also reduce the memory consumption by only loading part of the rows into memory at any given time. Notice that if you already have all data rows loaded into memory like a DataSet filled by the TableAdapter.Fill method, you will not have the performance gain with Virtual Mode. &lt;/P&gt;
&lt;P&gt;To demonstrate the ease of use of the PowerPacks DataRepeater control, let me give you a walkthrough for building an application with the DataRepeater control. &lt;/P&gt;
&lt;P&gt;First I would create a C# Windows Forms Application in Visual Studio 2008 SP1 or 2010 (yes, I purposely choose a C# project here to show that it is not only for VB, the steps in this demo have no difference between C# and VB).&lt;/P&gt;
&lt;P&gt;And then I want to create a DataSet data source with the &lt;A href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.100).aspx"&gt;DataSource Configuration Wizard&lt;/A&gt; or &lt;A href="http://msdn.microsoft.com/en-us/library/ms171897(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms171897(VS.100).aspx"&gt;DataSet Designer&lt;/A&gt;. I will assume you are familiar with this part and a DataSet with Employees table connecting to the sample Northwind database is ready to use. You will see that the &lt;A href="http://msdn.microsoft.com/en-us/library/6ckyxa83(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/6ckyxa83(VS.100).aspx"&gt;Data Sources Window&lt;/A&gt; on the left hand side is populated with the Employees Datatable (see Picture 1 bellow).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater1.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater1.jpg"&gt;&lt;IMG title=DataRepeater1 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=452 alt=DataRepeater1 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater1_thumb.jpg" width=754 border=0 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater1_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center&gt;Picture 1 – DataSet designer and Data Sources window.&lt;/P&gt;
&lt;P&gt;Now, let’s open the Form and show the Toolbox. You can find the Power Packs tab (see picture 2, marker 1, shortened as Pic.2-1), expand it and you will find the DataRepeater toolbox item (Pic.2-2). Drag and drop the DataRepeater toolbox item to the form (Pic. 2-3), you will see two sections in the location of the DataRepeater1 control on the form. The outer section (Pic.2-4) is the total display area of the control and the inner section (Pic.2-5, a.k.s. the Item Template section) holds the repeating items. It also defines the size of the repeating items and the location of the first item. You can fine tune the look and feel of the outer and inner section of the DataRepeater control as you wish. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater2.jpg"&gt;&lt;IMG title=DataRepeater2 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=385 alt=DataRepeater2 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater2_thumb.jpg" width=758 border=0 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater2_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center&gt;Picture 2. Drag and Drop DataRepeater to the Form&lt;/P&gt;
&lt;P&gt;I select my DataRepeater by clicking on the outer section of the DataRepeater, the Property Brower should show as in Pic. 3-1. And I set the anchor as top-left-right (Pic.3-2) and the &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.layoutstyle.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.layoutstyle.aspx"&gt;LayoutStyle&lt;/A&gt; as Horizontal (Pic. 3-3).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater3.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater3.jpg"&gt;&lt;IMG title=DataRepeater3 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=374 alt=DataRepeater3 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater3_thumb.jpg" width=762 border=0 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater3_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center&gt;Picture 3. DataRepeater layout&lt;/P&gt;
&lt;P&gt;Now, let’s fill the DataRepeater item template section with some data bound controls. I show the Data Sources Window (Pic. 4-1), change the employees table’s view to detail (Pic. 4-2), change the First and Last Name to label (Pic. 4-3), leave the Title as default TextBox (Pic. 4-4), and change the Photo to a PictureBox (Pic. 4-5). I then drag and drop these items to the DataRepeater item template section as indicated in the picture and remove the unnecessary extra labels. Note that it will also cause the auto creation of the navigator bar (Pic. 4-6), Dataset, BindingSource, TableAdapter, etc.(Pic. 4-7). The experience is exactly the same as when you drag and drop detail view items from the Data Sources window to a form or any container control. The difference is now the data bound items in the Item Template section will now be repeated at run time. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater4b.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater4b.jpg"&gt;&lt;IMG title=DataRepeater4b style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=400 alt=DataRepeater4b src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater4b_thumb.jpg" width=770 border=0 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeater4b_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center&gt;Picture 4. Drag and drop detail view items from Data Sources window to the item template section&lt;/P&gt;
&lt;P&gt;Now I am happy with the setup and eager to see what is out there, I hit F5 to test my app, and I got this result, that is all I need. You can scroll the data by clicking on the scroll bar or the forward and backward button on the navigation bar. You can select an item, and modify the value on any editable control on the item like Title text box (Pic. 5-1). You can add new item (Pic. 5-2), delete an item (Pic. 5-3). And you can save all the changes (Add/Delete/Update) with the save button (Pic. 5-4).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeaterBloggers3.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeaterBloggers3.jpg"&gt;&lt;IMG title=DataRepeaterBloggers3 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=429 alt=DataRepeaterBloggers3 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeaterBloggers3_thumb.jpg" width=771 border=0 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DataRepeaterControlforWindowsForms_C11C/DataRepeaterBloggers3_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center&gt;Picture 5. Run time result&lt;/P&gt;
&lt;P&gt;To summarize, creating a data binding application can be simply done with these 3 steps: 1) Create the data source; 2) Drag and drop a DataRepeater control to the form and adjust its look and feel; 3) Drag and drop detail view items from Data Sources Window to the item template section of the DataRepeater control.&lt;/P&gt;
&lt;P&gt;Lastly, let me wrap up with some more information: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The sample projects (VB and C# 2008 SP1 version) in this post can be found in MSDN Code Gallery &lt;A href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=PowerPacksSamples&amp;amp;ReleaseId=3098" mce_href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=PowerPacksSamples&amp;amp;ReleaseId=3098"&gt;Power Packs Samples&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;For a detail instruction of a similar walk through, see MSDN article: &lt;A href="http://msdn.microsoft.com/en-us/library/cc488274.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc488274.aspx"&gt;How to: Display Bound Data in a DataRepeater Control (Visual Studio)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;For a related video demonstration, see &lt;A href="http://go.microsoft.com/fwlink/?LinkId=143524" mce_href="http://go.microsoft.com/fwlink/?LinkId=143524"&gt;How Do I: Use the DataRepeater Control?&lt;/A&gt; &lt;EM&gt;p&lt;/EM&gt;&lt;EM&gt;resented by Beth Massi.&lt;/EM&gt;&lt;EM&gt; &lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;For MSDN DataRepeater introduction article: See &lt;A href="http://msdn.microsoft.com/en-us/library/cc488280.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc488280.aspx"&gt;Introduction to the DataRepeater Control (Visual Studio)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;For DataRepeater class reference: See &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.aspx"&gt;DataRepeater Class&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;For questions and feedback: See &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/threads" mce_href="http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/threads"&gt;Visual Basic Power Packs forum&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;For VB6 reference, see &lt;A href="http://msdn.microsoft.com/en-us/library/aa239070(VS.60).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa239070(VS.60).aspx"&gt;Data Repeater Control in Visual Basic 6&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;For accessing data technologies in Visual Studio: See &lt;A href="http://msdn.microsoft.com/en-us/library/wzabh8c4(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/wzabh8c4(VS.100).aspx"&gt;VS2010 Beta1 version&lt;/A&gt;&amp;nbsp; or &lt;A href="http://msdn.microsoft.com/en-us/library/wzabh8c4.aspx" mce_href="http://msdn.microsoft.com/en-us/library/wzabh8c4.aspx"&gt;VS2008 version&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;As mentioned above, my colleagues and I will post more articles to answer some advanced or non-obvious How-Tos in the near future. Stay tuned! &lt;/P&gt;
&lt;P&gt;----------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Follow-up blogs: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Calibri&gt;8/27/09 Gavin Fu:&amp;nbsp;&amp;nbsp;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/vsdata/archive/2009/08/27/how-to-change-appearance-of-all-datarepeater-items-at-run-time.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/08/27/how-to-change-appearance-of-all-datarepeater-items-at-run-time.aspx"&gt;&lt;FONT face=Calibri color=#800080 size=3&gt;How to Change Appearance of all DataRepeater Items at Run Time&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; &lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;9/8/09&amp;nbsp;John Chen &lt;A class="" href="http://blogs.msdn.com/vsdata/archive/2009/09/08/writing-event-handler-for-controls-in-a-datarepeateritem.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/09/08/writing-event-handler-for-controls-in-a-datarepeateritem.aspx"&gt;Writing Event Handler for controls in a DataRepeaterItem&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9867141" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/WinForm/default.aspx">WinForm</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VB+Power+Packs/default.aspx">VB Power Packs</category></item><item><title>Build Your Own Navigation Bar in WPF with Insert / Save / Delete Action</title><link>http://blogs.msdn.com/vsdata/archive/2009/08/08/build-your-own-navigation-bar-in-wpf-with-insert-save-delete-action.aspx</link><pubDate>Sat, 08 Aug 2009 19:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9861472</guid><dc:creator>XiaoyingGuo</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9861472.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9861472</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9861472</wfw:comment><description>&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;Some time ago, we built a&lt;/SPAN&gt;&lt;A href="http://blogs.msdn.com/vsdata/archive/2009/06/22/build-your-own-navigation-bar-for-data-navigation-in-wpf.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/06/22/build-your-own-navigation-bar-for-data-navigation-in-wpf.aspx"&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt; navigation bar&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt; for our WPF application to navigate data. We can make it even more powerful, and add CRUD support into it. Because we are using Entity Data Framework, it’s pretty easy to achieve this. Don’t believe it? Let’s first add the following buttons into our navigation bar we built late time: &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="28"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Left"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Margin&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="103,232,0,0"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="stackPanel2"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; VerticalAlignment&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Top"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Width&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="119"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Orientation&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Horizontal"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt; &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Background&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="BlanchedAlmond"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Content&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Insert"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; FontWeight&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Bold"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="23"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="insertButton"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Width&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Auto"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Click&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="insertButton_Click" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Background&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="BlanchedAlmond"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Content&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Save"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; FontWeight&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Bold"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="23"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="saveButton"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Width&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Auto"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Click&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="saveButton_Click"/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Background&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="BlanchedAlmond"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Content&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Delete"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; FontWeight&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Bold"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="23"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="deleteButton"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Width&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="Auto"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9.5pt"&gt; Click&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;="deleteButton_Click" /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 9.5pt"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;It’s something like below: &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1; mso-no-proof: yes"&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarinWPFwithInsert_15091/clip_image002_4.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarinWPFwithInsert_15091/clip_image002_4.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image002 border=0 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarinWPFwithInsert_15091/clip_image002_thumb_1.jpg" width=130 height=35 v:shapes="Picture_x0020_1" mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarinWPFwithInsert_15091/clip_image002_thumb_1.jpg"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&amp;nbsp;&lt;/SPAN&gt; 
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;Now let’s add the following event handler methods for each button: &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;1.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;STRONG&gt;Insert button.&lt;/STRONG&gt; Insert button adds a new empty entry for users to fill in data. &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;What we do here is pretty simple. We leverage the method IEditableCollectionViewSource.AddNew() to create a new entry into the current CollectionView. More info can be found &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.componentmodel.ieditablecollectionview.addnew.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.componentmodel.ieditablecollectionview.addnew.aspx"&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;here&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;. Because the EmployeeID is assigned in the table automatically when a new row is inserted, we don’t need users to fill in this item.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;The code looks like below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1"&gt;&lt;STRONG&gt;&lt;EM&gt;C#: &lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; insertButton_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;((&lt;SPAN style="COLOR: #2b91af"&gt;BindingListCollectionView&lt;/SPAN&gt;)(employeesViewSource__NorthwindEntities.View)).AddNew(); &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;employeeIDTextBox.Text = &lt;SPAN style="COLOR: #a31515"&gt;"{Auto-assigned}"&lt;/SPAN&gt;; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VB:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; insertButton_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt;) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(EmployeesViewSource__NorthwindEntities.View, &lt;SPAN style="COLOR: #2b91af"&gt;BindingListCollectionView&lt;/SPAN&gt;).AddNew()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;employeeIDTextBox.Text = &lt;SPAN style="COLOR: #a31515"&gt;"{Auto-assigned}"&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;2.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;STRONG&gt;Save button&lt;/STRONG&gt;. Save button saves the current data into database. &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;Let’s use ObjectContext.SaveChanges() to persist all updates to the database. SaveChanges method has an overload version SaveChanges(Boolean). If Boolean is set to false, then you have to call AccetpAllChanges() after calling SaveChanges(Boolean). For more information about this method, please check &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.savechanges.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.savechanges.aspx"&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;here&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;Here we also need to consider about concurrency errors. For more information about how to handle this, please see &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/y8fyz6xy(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/y8fyz6xy(VS.80).aspx"&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;here&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;The code looks like below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;STRONG&gt;C#: &lt;/STRONG&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; saveButton_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;try&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;northwindEntities.SaveChanges();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Update the number of rows in the table in case it's updated by data insertion.&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;UpdateNavigatorUI(); &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;catch&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;DBConcurrencyException&lt;/SPAN&gt; ex) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Add business logic code to resolve the concurrency violation...&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&amp;nbsp;&lt;/SPAN&gt; 
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt; 
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;STRONG&gt;&lt;EM&gt;VB:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; 
&lt;BLOCKQUOTE&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; saveButton_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt;) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Try&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NorthwindEntities&lt;/SPAN&gt;.SaveChanges() &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Update the number of rows in the table in case it's updated by data insertion.&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;UpdateNavigatorUI() &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Catch&lt;/SPAN&gt; ex &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.Data.&lt;SPAN style="COLOR: #2b91af"&gt;DBConcurrencyException&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Add business logic code to resolve the concurrency violation...&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Try&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;3.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;STRONG&gt;Delete button&lt;/STRONG&gt;. Delete button tends to delete the current entry.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;Here we instantiate an Employee object with the current item in the form and then use DeleteObject(TEntity) to do the deletion. However, the job isn’t submitted until users click Save button. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;STRONG&gt;C#: &lt;/STRONG&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; deleteButton_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Employee&lt;/SPAN&gt; employee = employeesViewSource__NorthwindEntities.View.CurrentItem as &lt;SPAN style="COLOR: #2b91af"&gt;Employee&lt;/SPAN&gt;; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;if (employee != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;northwindEntities.DeleteObject(employee); &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;}&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Update the row count number and the current row number in the navigation bar.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #00b050"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;UpdateNavigatorUI(); &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;VB:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; deleteButton_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt;) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; employee &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Employee&lt;/SPAN&gt; = &lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(EmployeesViewSource__NorthwindEntities.View.CurrentItem, &lt;SPAN style="COLOR: #2b91af"&gt;Employee&lt;/SPAN&gt;) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Not&lt;/SPAN&gt; (employee &lt;SPAN style="COLOR: blue"&gt;Is&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;Then&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NorthwindEntities&lt;/SPAN&gt;.DeleteObject(employee) &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End If&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Update the row count number and the current row number in the navigation bar&lt;/SPAN&gt; &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;UpdateNavigatorUI() &lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9.5pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal&gt;Done! Now we can hit F5 and play with it. Have fun!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9861472" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>Customize format of DateTime string in WPF and WinForm data binding</title><link>http://blogs.msdn.com/vsdata/archive/2009/07/07/customize-format-of-datetime-string-in-wpf-and-winform-data-binding.aspx</link><pubDate>Tue, 07 Jul 2009 06:17:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9821316</guid><dc:creator>Yang Cao</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9821316.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9821316</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9821316</wfw:comment><description>&lt;p&gt;Drag-and-drop data binding helps you build business applications very easily, however sometimes you still need to customize the layout or format after data binding is set. For example, I built a simple application to display all the Customers, and for each Customer, the related Orders are loaded into a DataGrid control:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_thumb_2.png" width="366" height="319" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Of course the data in Birthday field is fake :) and of course I don’t want to show the time part &lt;i&gt;12:00:00 AM&lt;/i&gt; in the text. To customize the string format, first let’s go to the XAML file and locate the TextBlock which binds to Birthday:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: #a31515; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;TextBlock&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Grid.Column&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Grid.Row&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Height&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;21&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Margin&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Name&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;birthdayTextBlock&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Text&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: #a31515; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;Binding&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Path&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=Birthday}&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Width&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;120&amp;quot; /&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt"&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You could write a converter to convert the string. Another simpler way is to insert a StringFormat property to the Text Binding and set it to only display the Date &lt;i&gt;1/1/2222&lt;/i&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;Text&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: #a31515; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;Binding&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt; Path&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;=Birthday,&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt; StringFormat&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;=d}&amp;quot;&lt;/span&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Similarly, if you set StringFormat to the “Order Date” and “Preferred Delivery Time” column:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri" lang="ZH-CN"&gt;…&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;        &lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: #a31515; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;TextBlock&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Text&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: #a31515; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;Binding&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Path&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=OrderDate,&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; StringFormat&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;={}{&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;0&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;dddd&lt;/span&gt;&lt;span style="color: red"&gt; MMMM dd&lt;/span&gt;&lt;span style="color: blue"&gt;}}&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-ascii-font-family: nsimsun"&gt;&amp;#160;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;        &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 12pt; mso-fareast-font-family: nsimsun"&gt;…&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt"&gt;        &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: #a31515; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;TextBlock&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Text&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: #a31515; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;Binding&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; Path&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=DeliveryDate,&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt; StringFormat&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri"&gt;=t}&amp;quot; /&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-ascii-font-family: nsimsun"&gt;&amp;#160;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt"&gt;        &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri" lang="ZH-CN"&gt;…&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;StringFormat&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;={}{&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;0&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;dddd&lt;/span&gt;&lt;span style="color: red"&gt; MMMM dd&lt;/span&gt;&lt;span style="color: blue"&gt;} &lt;/span&gt;&lt;/span&gt;it will display the DateTime in your specified format; &lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: red; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;StringFormat&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;NSimSun&amp;quot;,&amp;quot;serif&amp;quot;; color: blue; font-size: 9pt; mso-bidi-font-family: nsimsun; mso-fareast-font-family: nsimsun; mso-hansi-font-family: calibri; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;=t&lt;/span&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: simsun; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;&amp;#160;&lt;/span&gt;will only display short time. Now the form looks like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_thumb.png" width="366" height="310" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now you might ask, how about &lt;b&gt;WinForms&lt;/b&gt;? It is just as easy.     &lt;br /&gt;On the left is the WinForm Designer surface. Set focus on the DateTimePicker control and find Format property in Properties window. Change the Format to Short so that Birthday TextBlock will only display the Date:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_thumb_3.png" width="576" height="406" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;To set OrderDate column and PreferredDeliveryDate column to display in the format as in the WPF example above, click on the DataGridView control and click on the little smarttag button to open &lt;i&gt;DataGridView Tasks&lt;/i&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_thumb_4.png" width="535" height="374" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select Edit Columns to invoke &lt;i&gt;Edit Columns&lt;/i&gt; dialog, and in Bound Column Properties, select DefaultCellStyle to launch CellStyle Builder:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_13.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_thumb_5.png" width="382" height="240" /&gt;&lt;/a&gt; &lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_15.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_thumb_6.png" width="383" height="392" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There are some other customizations in this dialog, now let’s just focus on the Format. You could input Format like “dddd MM dd”, or launch Format String Dialog to set the string format. After setting format for both OrderDate column and PreferredDeliveryTime column, the final windows form is:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_19.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/CustomizeformatofDateTimefieldindatabind_CD85/image_thumb_8.png" width="366" height="345" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Well, isn’t it simple to change string format in data binding for both WPF and WinForm? To learn more about formatting (not only formatting DateTime string), please see: &lt;a href="http://msdn.microsoft.com/en-us/library/fbxft59x.aspx"&gt;http://msdn.microsoft.com/en-us/library/fbxft59x.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Cheers!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9821316" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/WinForm/default.aspx">WinForm</category></item><item><title>Build Your Own Navigation Bar for Data Navigation in WPF</title><link>http://blogs.msdn.com/vsdata/archive/2009/06/22/build-your-own-navigation-bar-for-data-navigation-in-wpf.aspx</link><pubDate>Mon, 22 Jun 2009 09:12:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9797163</guid><dc:creator>XiaoyingGuo</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9797163.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9797163</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9797163</wfw:comment><description>&lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;You may have known that drag-drop data-binding experience has been introduced to WPF application development story from VS2010 Beta1, thanks to a lot of posts before this one. The whole experience in WPF is pretty similar to what we’ve already had with WinForms: developers configure the bindings in Data Source Window and associate controls with data entities or properties, and drag-and-drop from Data Source Window to the designer generates controls with data binding set in the code. All looks familiar. But wait a second, you may find there is still something missing if you tend to generate a DataGrid or DetailsView for a data entity. You are right. In WPF, there’s no navigation bar facility, so drag-and-drop will only leave the exact control you are binding with the entity. However, using WPF, you will find it’s easy to do data navigation, thanks to the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx"&gt;&lt;font size="2"&gt;CollectionViewSource&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;. So why not build your own one and make it as whatever you like?&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;In this article, we will build a simple navigation bar leveraging &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx"&gt;&lt;font size="2"&gt;CollectionViewSource&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;. Below is what it looks like:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarforDataNavigati_9AFE/clip_image002_8.jpg"&gt;&lt;font size="2"&gt;&lt;img title="clip_image002" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="244" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarforDataNavigati_9AFE/clip_image002_thumb_2.jpg" width="233" border="0" v:shapes="Picture_x0020_1" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;To start, we use drag-drop WPF data-binding feature in VS2010 Beta 1 to generate a Details View of Employee entity. We use EDM here as data source. Let’s update the generated code behind a little bit and declare the entity, the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx"&gt;&lt;font size="2"&gt;CollectionViewSource&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;, and the query in a class wide. We also need to declare an int field member to get the total row counts of an entity, which looks like below:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;partial&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Window1&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;Window&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; WpfDataNavigationApplication.&lt;span style="color: #2b91af"&gt;NorthwindEntities&lt;/span&gt; northwindEntities = &lt;span style="color: blue"&gt;new&lt;/span&gt; WpfDataNavigationApplication.&lt;span style="color: #2b91af"&gt;NorthwindEntities&lt;/span&gt;();        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; System.Windows.Data.&lt;span style="color: #2b91af"&gt;CollectionViewSource&lt;/span&gt; employeesViewSource__NorthwindEntities;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; System.Data.Objects.&lt;span style="color: #2b91af"&gt;ObjectQuery&lt;/span&gt;&amp;lt;WpfDataNavigationApplication.&lt;span style="color: #2b91af"&gt;Employee&lt;/span&gt;&amp;gt; employeesQuery;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;int&lt;/span&gt; totalRowCount;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; Window1()        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;InitializeComponent();        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;     &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; System.Data.Objects.&lt;span style="color: #2b91af"&gt;ObjectQuery&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Employee&lt;/span&gt;&amp;gt; GetEmployeesQuery(&lt;span style="color: #2b91af"&gt;NorthwindEntities&lt;/span&gt; northwindEntities)        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: green"&gt;// Auto generated code&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;System.Data.Objects.&lt;span style="color: #2b91af"&gt;ObjectQuery&lt;/span&gt;&amp;lt;WpfDataNavigationApplication.&lt;span style="color: #2b91af"&gt;Employee&lt;/span&gt;&amp;gt; employeesQuery = northwindEntities.Employees;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: green"&gt;// Returns an ObjectQuery. &lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; employeesQuery;         &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;     &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Window_Loaded(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;employeesViewSource__NorthwindEntities = ((System.Windows.Data.&lt;span style="color: #2b91af"&gt;CollectionViewSource&lt;/span&gt;)(&lt;span style="color: blue"&gt;this&lt;/span&gt;.FindResource(&lt;span style="color: #a31515"&gt;&amp;quot;employeesViewSource__NorthwindEntities&amp;quot;&lt;/span&gt;)));        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;employeesQuery = &lt;span style="color: blue"&gt;this&lt;/span&gt;.GetEmployeesQuery(northwindEntities);        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;employeesViewSource__NorthwindEntities.Source = employeesQuery.Execute(System.Data.Objects.&lt;span style="color: #2b91af"&gt;MergeOption&lt;/span&gt;.AppendOnly);        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;br /&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;Then it’s the time to build the navigation bar! Let’s start with UI design and make something like this:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarforDataNavigati_9AFE/clip_image004_8.jpg"&gt;&lt;font size="2"&gt;&lt;img title="clip_image004" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="30" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/BuildYourOwnNavigationBarforDataNavigati_9AFE/clip_image004_thumb_2.jpg" width="210" border="0" v:shapes="Picture_x0020_3" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;From the left to the right, they are buttons for navigation to the first row, the previous row, the next row, and the last row; a text box for users to input the index of the row for navigation; a label to show how many row in all; and a button for navigation to the specific row based on what users input into the text box. We also add event handler for each button. The XAML of this navigation bar looks like below:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;StackPanel&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;28&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Margin&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;10,12,0,0&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;stackPanel1&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;206&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Orientation&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Horizontal&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Content&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;|&amp;amp;lt;&amp;amp;lt;&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToFirstButton&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; FontWeight&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Background&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;BlanchedAlmond&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Click&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToFirstButton_Click&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Content&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;&amp;amp;lt;&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToPreviousButton&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; FontWeight&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Background&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;BlanchedAlmond&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Click&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToPreviousButton_Click&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Content&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;&amp;amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToNextButton&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; FontWeight&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Background&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;BlanchedAlmond&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Click&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToNextButton_Click&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Content&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;&amp;amp;gt;&amp;amp;gt;|&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToLastButton&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; FontWeight&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Background&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;BlanchedAlmond&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Click&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goToLastButton_Click&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;TextBox&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goTextBox&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;37&amp;quot; /&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Label&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Content&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;of &amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;28&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;label1&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;20&amp;quot; /&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Label&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;28&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt; &lt;span style="color: blue"&gt;totalRowCount&amp;quot;&lt;/span&gt;&lt;span style="color: red"&gt; Width&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;25&amp;quot; /&amp;gt;&lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Content&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Go!&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Height&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Name&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goButton&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Width&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Background&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;BlanchedAlmond&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; FontWeight&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: &amp;quot;Courier New&amp;quot;"&gt; Click&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;=&amp;quot;goButton_Click&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;Button&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: #a31515; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;StackPanel&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;And in the code behind, we get a set of event handler methods for each button’s Click event.&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;Now it’s the time to implement navigation! Still remember we load data into a &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx"&gt;&lt;font size="2"&gt;CollectionViewSource&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;? Now it’s the time to leverage its power. &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx"&gt;&lt;font size="2"&gt;CollectionViewSource&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; is actually a XAML proxy for &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionview.aspx"&gt;&lt;font size="2"&gt;CollectionView&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; class, which represents a View for grouping, sorting, filtering and navigating a data collection. The View provides a currency point and allows you to move the pointer. As a proxy of &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionview.aspx"&gt;&lt;font size="2"&gt;CollectionView&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; class, CollectionViewSource has a View property, which is a dependency property. We’ll use this to move the currency and do navigation. So, for each Click event handler, the implementation is somewhat like below:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; GoToFirstButton_Click(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)          &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;employeesViewSource_NorthwindEntities.View.MoveCurrentToFirst();        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;     &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; GoToPreviousButton_Click(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;employeesViewSource_NorthwindEntities.View.MoveCurrentToPrevious();        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;     &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; GoToNextButton_Click(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;employeesViewSource_NorthwindEntities.View.MoveCurrentToNext();        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;     &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; GoToLastButton_Click(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;employeesViewSource_NorthwindEntities.View.MoveCurrentToLast();        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;     &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; GoButton_Click(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt; position;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;.TryParse(goTextBox.Text, out position);         &lt;p&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (position &amp;gt; 0 &amp;amp;&amp;amp; position &amp;lt;= totalRowCount)&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;{       &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 1in; text-indent: 0.5in; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;employeesViewSource_NorthwindEntities.View.MoveCurrentToPosition(position - 1);       &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}          &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;else         &lt;p&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color: #a31515"&gt;&amp;quot;The input index is not valid.&amp;quot;&lt;/span&gt;);        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;To get the total row counts, we need to use the Count method in entity’s ObjectSet. Let’s put the following code into the Window_Loaded method:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; totalRowCount = northwindEntities.Employees.Count();         &lt;p&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;totalRowCountLabel.Content = totalRowCount;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;So far, we’ve already had our navigation work. Pretty simple, isn’t it?&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;To make it even better, let’s do something more on the button, and disable the button when it doesn’t make sense to click it. We’ll add a new method here to set buttons’ ability:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; SetButtonIsEnabled()        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCommentText" style="margin-bottom: 0pt"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-tab-count: 1"&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;bool&lt;/span&gt; isFirst = (employeesViewSource__NorthwindEntities.View.CurrentPosition == 0);&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCommentText" style="margin-bottom: 0pt"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;bool&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt; isLast&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;= employeesViewSource__NorthwindEntities.View.CurrentPosition &amp;gt; (totalRowCounts - 1);        &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoCommentText" style="margin-bottom: 0pt"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;     &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCommentText" style="margin-bottom: 0pt"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;goToFirstButton.IsEnabled = goToPreviousButton.IsEnabled = !isFirst;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;goToNextButton.IsEnabled = goToLastButton.IsEnabled = !isLast;        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt"&gt;&lt;span style="font-size: 9.5pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;Also, we’d like the index input text box always shows the corresponding index number for the current selection. So we need another method here:&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; SetGoTextBoxOnCurrentPosition()        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;goTextBox.Text = (employeesViewSource__NorthwindEntities.View.CurrentPosition + 1).ToString();        &lt;p&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;"&gt;&lt;font size="2"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;Then we can call these two methods in the Click event handler methods (or wrap these two methods into a new method, say UpdateNavigatorUI, and call the method), and we’ll get a complete functionality of a basic navigation bar. The full code can be found &lt;a href="http://blogs.msdn.com/vsdata/pages/full-sample-code-behind-in-data-navigatior.aspx"&gt;here&lt;/a&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;Based on that, we can add even more features into our navigation bar. To make it more powerful, you can also add CRUD functionality into it. However, hmm… In this article, the navigation bar we build only work for one page and one entity. There still some work we can do to make this useful utility more reusable. How we can do that? Bingo! Building a user control. And we will talk about that in the future post. Wait and see!&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9797163" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category></item><item><title>WPF Data Binding: Lookup tables</title><link>http://blogs.msdn.com/vsdata/archive/2009/06/18/wpf-data-binding-lookup-tables.aspx</link><pubDate>Thu, 18 Jun 2009 06:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9771358</guid><dc:creator>MilindLele</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9771358.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9771358</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9771358</wfw:comment><description>&lt;P&gt;&lt;FONT size=2 face=Verdana&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Verdana&gt;A few weeks ago I wrote about &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/vsdata/archive/2009/05/20/wpf-data-binding-creating-a-master-details-form-in-visual-studio-2010.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/05/20/wpf-data-binding-creating-a-master-details-form-in-visual-studio-2010.aspx"&gt;&lt;FONT size=2 face=Verdana&gt;creating a master-details form&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2 face=Verdana&gt;, where we looked at an example of a database used for tracking orders, as part of an order management system. We had used the Customers and Orders tables and built a master-details form that showed a list of customers and for each selected customer, their orders. Another common scenario for binding &lt;EM&gt;related&lt;/EM&gt; tables on a form involves look up tables.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Verdana&gt;Beth Massi wrote about &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/04/30/data-binding-wpf-lookup-combobox-values-to-ef-entities.aspx" mce_href="http://blogs.msdn.com/bethmassi/archive/2009/04/30/data-binding-wpf-lookup-combobox-values-to-ef-entities.aspx"&gt;&lt;FONT size=2 face=Verdana&gt;how to data bind WPF lookup comboboxes to entities&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2 face=Verdana&gt; using VS2008. She uses describes the XAML and the code behind one needs to write to accomplish this. In VS2010, it’s considerably easier. Here’s how:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Verdana&gt;We will use the same Customers and Orders tables and entities that Beth uses (and we’ve used in my previous master-details post). Once we create a WPF application and add an entity model to to it as described in earlier posts, we should be able to browse the entity model in the data sources window. In the data sources window:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT size=2 face=Verdana&gt;Expand the Orders node and under it set the FK_Orders_Customer to a combobox &lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_4.png"&gt;&lt;FONT size=2 face=Verdana&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_thumb_1.png" width=220 height=143 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_thumb_1.png"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2 face=Verdana&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size=2 face=Verdana&gt;Select the Orders node and set the control to Details view &lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_6.png"&gt;&lt;FONT size=2 face=Verdana&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_thumb_2.png" width=194 height=158 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_thumb_2.png"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2 face=Verdana&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size=2 face=Verdana&gt;Drag and drop the Orders entity to the WPF form &lt;BR&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size=2 face=Verdana&gt;Now drag and drop the LastName property under FK_Orders_Customer to the combobox on the form.&lt;/FONT&gt; &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;FONT size=2 face=Verdana&gt;Just these four simple steps will get the look up binding setup. The application, when run, would look something like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_8.png"&gt;&lt;FONT size=2 face=Verdana&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_thumb_3.png" width=244 height=182 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingLookuptables_100B8/image_thumb_3.png"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2 face=Verdana&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Verdana&gt;The XAML for the combobox is something like this:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2 face=Verdana&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;ComboBox&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt; Name&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="CustomerComboBox"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;Height&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="23"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt; Width&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="120"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;HorizontalAlignment&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="Left" &lt;FONT color=#ff0000&gt;VerticalAlignment&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="Center" &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="3"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DisplayMemberPath&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="Customer.LastName"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;ItemsSource&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;="{&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;Binding&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;}"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9771358" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>WPF Sample on CodeGallery</title><link>http://blogs.msdn.com/vsdata/archive/2009/06/11/wpf-sample-on-codegallery.aspx</link><pubDate>Thu, 11 Jun 2009 23:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9727900</guid><dc:creator>MilindLele</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9727900.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9727900</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9727900</wfw:comment><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;BR&gt;&lt;FONT size=3 face=Calibri&gt;The MSDN CodeGallery now has VB and C# sample for WPF data binding&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;A href="http://code.msdn.microsoft.com/WPFDatabinding"&gt;&lt;FONT size=3 face=Calibri&gt;http://code.msdn.microsoft.com/WPFDatabinding&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&lt;FONT size=3 face=Calibri&gt;This is a sample of a WPF application and includes data binding, data validation, lookup binding. The solution is VS2010 Beta1 based, but the application uses .NET Framework 3.5.&lt;BR&gt;&lt;BR&gt;See also: &lt;/FONT&gt;&lt;A href="http://code.msdn.microsoft.com/wpfdatavideos"&gt;&lt;FONT size=3 face=Calibri&gt;Beth Massi’s WPF Forms over data videos using VS2008&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9727900" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>WPF Data Binding: Bind a generic object on a WPF designer</title><link>http://blogs.msdn.com/vsdata/archive/2009/06/01/wpf-data-binding-bind-a-generic-object-on-a-wpf-designer.aspx</link><pubDate>Mon, 01 Jun 2009 22:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9674228</guid><dc:creator>Jeff Chen</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9674228.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9674228</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9674228</wfw:comment><description>&lt;P&gt;In Visual Studio 2010 Beta1, we have enabled data binding experience for a few data sources on WPF designer. Generic object or business object is one of them. Besides this, we have also supported multiple object selection in data source configuration wizard. I will show you all of the above features by walking through one example. In this example, I want to create a master-details form on a WPF designer by binding to the generic objects.&lt;/P&gt;
&lt;P&gt;First, let’s create two classes called Customer and Order. And we establish one-to-many relationship between Customer and Order. This step is pretty similar to what needs to be done on a Winform designer.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb.png" width=320 height=221 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Second, let’s add these two generic objects to data sources window. As I mentioned above, we now support selecting multiple objects in data source configuration wizard simultaneously.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_4.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb_1.png" width=323 height=252 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the addition, this is what displays in data sources window.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb_2.png" width=121 height=261 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Third, let’s drag-drop from data sources window to the WPF designer to create a master-details form. We can bind any system or user controls to a particular data node. Here are the helps on &lt;A href="http://msdn.microsoft.com/en-us/library/dd264902(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd264902(VS.100).aspx"&gt;“Customize Control Binding Dialog Box”&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/5554bf3a(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/5554bf3a(VS.100).aspx"&gt;“How to: Add Custom Controls to the Data Sources Window”&lt;/A&gt;. In this example, I bind ListBox to the node Customer.LastName and DataGrid to the node Customer.Orders in the data sources window, and drag-drop these nodes to the WPF designer respectively.&lt;/P&gt;
&lt;P&gt;Last, we need to fill the data to the form. In the third step, when we drag-drop the data nodes to the form, XAML code was automatically generated. That XMAL code is very similar to the one if we bind data to ADO.NET Entity Data Model. You can find detailed explanation about XAML code part in MilindLele’s post &lt;A href="http://blogs.msdn.com/vsdata/archive/2009/05/20/wpf-data-binding-creating-a-master-details-form-in-visual-studio-2010.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/05/20/wpf-data-binding-creating-a-master-details-form-in-visual-studio-2010.aspx"&gt;“WPF Data Binding: Creating a Master-Details form in Visual Studio 2010”&lt;/A&gt;. For the code behind the form, we set the data to the source property of the CollectionViewSource of the Customer object in the window loaded event handler.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE class=csharpcode&gt;List&amp;lt;Customer&amp;gt; customers = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; List&amp;lt;Customer&amp;gt;(); 
customers.Add(...);

System.Windows.Data.CollectionViewSource customerViewSource = 
  ((System.Windows.Data.CollectionViewSource)(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.FindResource(&lt;SPAN class=str&gt;"customerViewSource"&lt;/SPAN&gt;))); 
customerViewSource.Source = customers;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now press F5, we should be able to see the form loaded with the data.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_8.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb_3.png" width=320 height=202 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/WPFDataBindingBindagenericobjectonaWPFde_C1D4/image_thumb_3.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;As the master-details association is already created in XAML, different sets of orders will be displayed according to the selection of customer names.&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:0767317B-992E-4b12-91E0-4F059A8CECA8:627849d7-d2af-48b0-b53f-3572cf75b762 class=wlWriterEditableSmartContent&gt;Technorati Tags: &lt;A href="http://technorati.com/tags/WPF" rel=tag mce_href="http://technorati.com/tags/WPF"&gt;WPF&lt;/A&gt;,&lt;A href="http://technorati.com/tags/Business+Object" rel=tag mce_href="http://technorati.com/tags/Business+Object"&gt;Business Object&lt;/A&gt;,&lt;A href="http://technorati.com/tags/Generic+Object" rel=tag mce_href="http://technorati.com/tags/Generic+Object"&gt;Generic Object&lt;/A&gt;,&lt;A href="http://technorati.com/tags/VS2010+Beta1" rel=tag mce_href="http://technorati.com/tags/VS2010+Beta1"&gt;VS2010 Beta1&lt;/A&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9674228" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Generic+Object/default.aspx">Generic Object</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Business+Object/default.aspx">Business Object</category></item><item><title>Improvement of the data binding experience with ADO.Net Data Services</title><link>http://blogs.msdn.com/vsdata/archive/2009/05/25/improvement-of-the-data-binding-experience-with-ado-net-data-service.aspx</link><pubDate>Tue, 26 May 2009 00:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9640871</guid><dc:creator>John Chen</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9640871.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9640871</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9640871</wfw:comment><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;FONT size=3&gt;In Visual Studio 2010 Beta1, the data binding experience with ADO.Net Data Services has been improved. In Visual Studio 2008 SP1, after adding an ADO.Net data service as web reference to a client project, it will not automatically show up in the data source window, you have to add an object data source to consume the ADO.Net data service. There is no more of this step in VS2010!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;FONT size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;FONT size=3&gt;Let's take a look at the article of &lt;SPAN style="COLOR: #0070c0"&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc668184.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc668184.aspx"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;Walkthrough: Creating and Accessing an ADO.NET Data Service in Visual Studio&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt; (this is for VS2008 SP1). To create the client application consuming the ADO.Net data service, you have the following steps: &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; mso-list: l0 level1 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3&gt;1)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;&lt;FONT size=3&gt;Create the client application &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;(Steps omit here) &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; mso-list: l0 level1 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3&gt;2)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;&lt;FONT size=3&gt;Add a service reference &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;a)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;On the Project menu, click Add Service Reference. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;b)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;In the Add Service Reference dialog box, click Discover. &lt;BR&gt;The URL for the NorthwindCustomers service will appear in the Address field. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;c)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;Click OK to add the service reference. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; mso-list: l0 level1 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3&gt;3)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;&lt;FONT size=3&gt;Enable data binding to the service &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;a)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;On the Data menu, click Show Data Sources. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;b)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;In the Data Sources window, click Add New Data Source. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;c)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;On the Choose a Data Source Type page of the Data Source Configuration Wizard, click Object, and then click Next. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;d)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;On the Select the Object You Wish to Bind to page, expand the NorthwindClient node, and then expand the NorthwindClient.ServiceReference1 node. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; VERTICAL-ALIGN: middle; mso-list: l0 level2 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;e)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;Select Customers, and then click Finish. &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; mso-list: l0 level1 lfo4" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: tahoma; mso-bidi-font-weight: bold"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3&gt;4)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;&lt;FONT size=3&gt;Create the user interface &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;(Steps omit here) &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;In VS2010 beta1, you do not need to do step 3 anymore. ADO.Net data service is recognized automatically and happily shows up in the data source window. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;Alternatively, you can also add the ADO.net data service to your client project by the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/w4dd7z6t(VS.80).aspx"&gt;&lt;FONT color=#800080 size=3&gt;Data Source Configuration Wizard&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;. Replace the step 2 above with the following: &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&amp;nbsp; &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; mso-list: l1 level1 lfo1; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: tahoma"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;On the Data menu, click Show Data Sources. &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; mso-list: l1 level1 lfo2; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: tahoma"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3&gt;b.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;In the Data Sources window, click Add New Data Source. &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; mso-list: l1 level1 lfo3; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: tahoma"&gt;&lt;SPAN style="mso-list: ignore"&gt;&lt;FONT size=3&gt;c.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;On the Choose a Data Source Type page of the Data Source Configuration Wizard, click &lt;SPAN style="BACKGROUND: yellow; mso-highlight: yellow"&gt;Service&lt;/SPAN&gt;, and then click Next. The next page will be the Add Service Reference dialog box. Now you just do the same thing just as adding the service reference through Add Service Reference project menu. &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/Blog1_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/Blog1_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=Blog1 border=0 alt=Blog1 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/Blog1_thumb.jpg" width=511 height=401 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/Blog1_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;At the end of Add service reference or the Data Source Configuration Wizard, you will see the following in the data source window (for the example in &lt;A href="http://msdn.microsoft.com/en-us/library/cc668184.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc668184.aspx"&gt;the walkthrough&lt;/A&gt;). &lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 27pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog2_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog2_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=blog2 border=0 alt=blog2 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog2_thumb.jpg" width=281 height=190 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog2_thumb.jpg"&gt;&lt;/A&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;Even more, if you update the ADO.Net data service, e.g. adding Orders to the EDM, and update the service reference, the data source window will update accordingly as the example shown bellow.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog3_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog3_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=blog3 border=0 alt=blog3 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog3_thumb.jpg" width=295 height=162 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/Improvementofthedatabindi.NetDataService_CC8F/blog3_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;FONT size=3&gt;Cheers! &lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9640871" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Data+Binding/default.aspx">Data Binding</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/ADO.Net+Data+Services/default.aspx">ADO.Net Data Services</category></item></channel></rss>