Attributes | Values |
---|
type
| |
Date Created
| |
Date Modified
| |
label
| |
maker
| |
Title
| |
isDescribedUsing
| |
has creator
| |
attachment
| |
content
| - %META:TOPICPARENT{name="VirtSPASQLWebDataServiceApp"}%
---+ Creating a Silverlight Application to consume the service
%TOC%
---++ Introduction
This document will guide you through creating an application for Silverlight that will consume
the ADO.NET Data Service created in
[[VirtSPASQLWebDataServiceApp][Creating a Web Browser Application to Access RDF Data using the Virtuoso ADO.NET Provider]].
---++ Prerequisites
1 The
[[http://www.microsoft.com/downloads/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&displaylang=en][Microsoft Silverlight 2 Tools for Visual Studio 2008 SP1]]
1 The ADO.NET Data Service created in
[[VirtSPASQLWebDataServiceApp][Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.NET Provider]]
1 The Visual Studio project used to create the ADO.NET Data Service
---++ Creating the Application for Silverlight
1 Open the ADO.NET Data Service project in <b>Visual Studio</b>.
1 In the <b>Solution Explorer</b> right click on the <nowiki>RDFWebDemo</nowiki> solution and add a new Project.
1 In the <b>Add New Project</b> dialog select <b>Silverlight Application</b> and click <b>OK</b>.
This will open the <b>Add Silverlight Application</b> dialog.
%BR%%BR%<img src="%ATTACHURLPATH%/SilverlightApp.png" style="wikiautogen"/>%BR%%BR%
1 Select <b>Link this Silverlight Control into an existing Web Site</b> and make sure the Web Site
selected is <nowiki>RDFWebDemo</nowiki>. Select <b>Add a test page that references the application</b>
and <b>Make it the start page</b>.
%BR%%BR%<img src="%ATTACHURLPATH%/AddSilverlightApp.png" style="wikiautogen"/>%BR%%BR%
1 In <b>Solution Explorer</b>, select <b><nowiki>RDFWebDemo</nowiki></b>, open the <b>Project</b>
menu and select <b>Properties</b>.
1 Select the <b>Web</b> tab, and select <b>Specific Page</b> in the <b>Start Action</b> section.
Click on the ellipsis ("<b>?</b>") and select <b><nowiki>SilverlightApplication1TestPage.html</nowiki></b>
as the start page.
1 Add a reference to the data service. In the <b>Solution Explorer</b> right click on
<b><nowiki>SilverlightApplication1</nowiki></b> and select <b>Add Service Reference</b>.
1 In the <b>Add Service Reference</b> dialog click the <b>Discover</b> button. Your ADO.NET
Data Service should appear in the Address box and the Services box.
1 Select the service and click <b>OK</b>. <b><nowiki>ServiceReference1</nowiki></b> will now
be added to the <b><nowiki>ServiceReferences</nowiki></b>.
1 Open <b>page.xaml.cs</b> and add references to the service and to the
<b>System.Data.Services.Client</b> assembly by adding the following using statements at the top
of the file:
<verbatim>
using System.Data.Services.Client;
using SilverlightApplication1.ServiceReference1;
</verbatim>
1 We need to create a data service context to reference the data from the service and to load
data from the view, <code>sparqlview</code>, exposed by the service. Add the following lines to
the page constructor after <b><nowiki>InitializeComponent()</nowiki></b> —
<verbatim>
DataServiceContext svcCtx = new DataServiceContext(new Uri("WebDataService1.svc", UriKind.Relative));
svcCtx.BeginExecute<sparqlview>(new Uri("sparqlview", UriKind.Relative), loadSCallback, svcCtx);
</verbatim>
1 Add the <b><nowiki>loadSCallback</nowiki></b> 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.
<verbatim>
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;
}
</verbatim>
1 Add the list box to the page. In the <b>Solution Explorer</b> double click on <b>page.xaml</b>
to open it in the editor. Add the following code between the <grid> and </grid> tags.
<verbatim>
<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>
</verbatim>
1 Build the Silverlight application and launch without debugging using <b>Ctrl-F5</b>. This
will launch the browser and open <code>SilverlightApplication1TestPage.aspx</code>.
%BR%%BR%<img src="%ATTACHURLPATH%/browser.png" style="wikiautogen"/>%BR%%BR%
Clicking on one of the IRIs will open the page using <code>description.vsp</code>.
%BR%%BR%<img src="%ATTACHURLPATH%/Description.png" style="wikiautogen"/>%BR%%BR%
---++ Related
* [[VirtAdoNetDataGridApp][Using Visual Studio 2008 to Build a Data Grid Form Application]]
* [[VirtEntityFrameworkSchoolDbWinFormApp][Using Visual Studio 2008 to Build an Entity Frameworks-based Windows Form Application]]
* [[VirtUsingMsAdoNetDataServicesWithVirtuoso][Using Visual Studio 2008 to Build an ADO.NET Data Services-based Application]]
* [[VirtSPASQLWinFormApp][Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.NET Provider]]
* [[VirtSPASQLWebDataServiceApp][Web Data Service Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.NET Provider]]
|
id
| - ce2197840abe15bfe7998aa6035dc57c
|
link
| |
has container
| |
http://rdfs.org/si...ices#has_services
| |
atom:title
| |
links to
| |
atom:source
| |
atom:author
| |
atom:published
| |
atom:updated
| |
topic
| |
is made
of | |
is container of
of | |
is link
of | |
is http://rdfs.org/si...vices#services_of
of | |
is links to
of | |
is creator of
of | |
is atom:entry
of | |
is atom:contains
of | |