Share via


Exercise 4: Add In-Memory Update Functionality to the Silverlight Application

In this exercise you will finish the Silverlight application. You will add functionality to update the in-memory Excel Workbook and retrieving updated calculated values.

Task 1– Updating the MainPage.xaml.cs View.

  1. Right-click on MainPage.xaml in Solution Explorer and select View Code.
  2. Use snippet 4.4.10 to modify the existing TextChanged event handler. This event updates the bound data in the ViewModel.

    Figure 29

    textbox_DiscountChanged

Task 2 – Deploying and Testing the Silverlight Application.

  1. Right-click on the SharePoint.Client.ExcelRest project in Solution Explorer and select Set as StartUp Project.
  2. Press F5 to build and deploy.
  3. Use Internet Explorer to navigate to https://intranet.contoso.com/ExcelRestDemo.aspx
  4. Click the Product drop down and select a Vulcan Gear.

    Figure 30

    Product screen

  5. Change the Discount from 10 percent to 30 percent. The Sale Price changes from 188.99 to $146.99 and the Profit Margin changed from 71.8 % to 33.6%.

    Figure 31

    Product screen

  6. The calculation of the product’s Profit Margin and Sales Price is located in the Excel Workbook and not calculated by the Silverlight application. The Url used in the GetDetails method passes in the current Discount value. The details are recalculated with the request for the details using the new Discount value.

    Figure 32

    excelRestUri string

  7. Navigate to https://intranet.contoso.com.
  8. Navigate to https://intranet.contoso.com/ExcelRestDemo.aspx

    Click the Product drop down and select a Vulcan Gear.

    Figure 33

    Product screen

Notice the original 10% Discount value displays. “Updating” fields using Rest Urls do not persist to the Excel Workbook. Passing in updated values are in-memory only.