www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Installation Guide

Virtuoso on All platforms Commmon Specifics
Virtuoso for Windows
Virtuoso for Linux (Enterprise Edition)
Virtuoso for Unix (Enterprise Edition)
Virtuoso for Unix (Personal Edition)
Virtuoso for Mac OS X
OpenLink License Management
Virtuoso ADO.Net Data Grid Form Application
Using Visual Studio 2008 to Build an Entity Frameworks based Windows Form Application
Using Visual Studio 2008 to Build an ADO.NET Data Services based Application
Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.Net Provider
Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.Net Provider
Creating a Silverlight Application to consume the service
Pre-requisites Creating the Application for Silverlight.
Creating A Simple .NET RIA Services Application To Display Data From Virtuoso
Creating a .Net RIA Services Application That Will Update Virtuoso Data
Cluster Installation and Config

2.13. Creating a Silverlight Application to consume the service

This section will guide you through creating an application for Silverlight that will consume the ADO.Net Data Service created in Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.Net Provider.

2.13.1. Pre-requisites

  1. The Microsoft Silverlight 2 Tools for Visual Studio 2008 SP1
  2. The ADO.Net Data Service created in Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.Net Provider.
  3. The Visual Studio project used to create the ADO.Net Data Service.

2.13.2. Creating the Application for Silverlight.

  1. Open the ADO.Net Data Service project in Visual Studio
  2. In the Solution Explorer right click on the RDFWebDemo solution and add a new Project.
  3. In the Add New Project dialog select Silverlight Application and click OK. This will open the Add Silverlight Application dialog.
    Add Silverlight Application
    Figure: 2.13.2.1. Add Silverlight Application
  4. Select Link this Silverlight Control into an existing Web Site and make sure the Web Site selected is RDFWebDemo. Select Add a test page that references the application and Make it the start page.
    Add a test page
    Figure: 2.13.2.1. Add a test page
  5. In Solution Explorer, select RDFWebDemo, open the Project menu and select Properties.
  6. Select the Web tab, and select Specific Page in the Start Action section. Click on the ellipsis and select SilverlightApplication1TestPage.html as the start page.
  7. Add a reference to the data service. In the Solution Explorer right click on SilverlightApplication1 and select Add Service Reference
  8. In the Add Service Reference dialog click the Discover button. Your ADO.Net Data Service should appear in the Address box and the Services box.
  9. Select the service and click OK. ServiceReference1 will now be added to the ServiceReferences.
  10. Open page.xaml.cs and add references to the service and to the System.Data.Services.Client assembly by adding the following using statements at the top of the file:
    using System.Data.Services.Client;
    using SilverlightApplication1.ServiceReference1;
    
  11. We need at create a data service context to reference the data from the service and to load data from the view, sparqlview, exposed by the service. Add the following lines to the page constructor after InitializeComponent()
    DataServiceContext svcCtx = new DataServiceContext(new Uri("WebDataService1.svc", UriKind.Relative));
    svcCtx.BeginExecute<sparqlview>(new Uri("sparqlview", UriKind.Relative), loadSCallback, svcCtx);
    
  12. Add the loadSCallback method to the page class. The method loads the data from sparqlview and puts it in a List. This List populates a list box on the page.
    private void loadSCallback(IAsyncResult asyncResult)
    {   List<Uri> uList = new List<Uri>();
        DataServiceContext ctx = asyncResult.AsyncState as DataServiceContext;
        foreach (sparqlview sv in ctx.EndExecute<sparqlview>(asyncResult))
         uList.Add(new Uri(sv.s));
        listBox1.DataContext = uList;
    }
    
  13. Add the list box to the page. In the Solution Explorer double click on page.xaml to open it in the editor. Add the following code between the <grid> and </grid> tags.
    <ListBox x:Name="listBox1"
        HorizontalAlignment="Stretch"
        Margin="25,8,26,-78" Grid.RowSpan="1"
        Grid.Row="0" VerticalAlignment="Stretch"
        ItemsSource="{Binding Mode=OneWay}" >
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel x:Name="DisplayListData"
                 Orientation="Horizontal"
                 VerticalAlignment="Bottom"
                 Margin="5" >
                    <HyperlinkButton
                     Content ="{Binding}"
                     NavigateUri="{Binding}"
                     Margin="5,0,0,0"
                     VerticalAlignment="Bottom"
                     HorizontalAlignment="Left"
                     FontSize="12">
                    </HyperlinkButton>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    
  14. Build the Silverlight application and launch without debugging using Ctrl F5. This will launch the browser and open SilverlightApplication1TestPage.aspx.
    SilverlightApplication1TestPage.aspx
    Figure: 2.13.2.1. SilverlightApplication1TestPage.aspx

Clicking on one of the IRIs will open the page using description.vsp.

using description.vsp
Figure: 2.13.2.1. using description.vsp