12
Week 4 – Applications, Resources, and Deployment Jim LaVine jim.lavine @gmail.com

IEDOTNETUG Silverlight Class Week 4

Embed Size (px)

DESCRIPTION

Applications, resources, and deployment

Citation preview

Page 1: IEDOTNETUG Silverlight Class Week 4

Week 4 – Applications,

Resources, and Deployment

Jim LaVinejim.lavine @gmail.com

Page 2: IEDOTNETUG Silverlight Class Week 4

Agenda• Loading the application• XAP files• Binary resources• Xaml resources• Application class• Application extensions

Page 3: IEDOTNETUG Silverlight Class Week 4

Loading the Plugin• HTML <object> tag

– Compiled Silverlight content– Splash / download UI– Error Handling– Fallback content

Page 4: IEDOTNETUG Silverlight Class Week 4

Code Behind<object id=“slPlugin” width=“100%” height=“100%

type=“application/x-silverlight-2” data=“data:application/x-silverlight-2,”>

<param name=“source” value=“client/bin/SLContent.xap” />

<param name=“onerror” value=“onSilverlightError” />

<param name=“minRuntimeVersion” value=“4.0.50401 .0” /><param name=“autoUpgrade” value=“true” />

<a href=“http:go.microsoft.com/fwlink/?linkid=115261” style=“text-decoration: none;> <img src=“http:go.microsoft.com/fwlink/?linkid=108181” alt=“Get Microsoft Silverlight” style=“border-style: none”/></a>

</object>

Page 5: IEDOTNETUG Silverlight Class Week 4

Silverlight.js• Benefits– Silverlight.IsInstalled helper– Can choose content at runtime

• Disadvantages– More Complex– Extra file to download– Moving Target

Page 6: IEDOTNETUG Silverlight Class Week 4

Using Silverlight.js<script type="text/javascript" src="Silverlight.js"></script>…<div id=“slPLaceholder”></div>…<script type="text/javascript"> Silverlight.createObject( "ClientBin/SLObject.xap", document.getElementById("slPlaceholder"), "slControl", {width:"500" heigth:"500", version:'4.0'}, {onError: myErrorHandler} );</script>

Page 7: IEDOTNETUG Silverlight Class Week 4

XAP• Just a Zip

– Main DLL– Dependent DLLs– Resources– Mainfest

• Server config– Mime type for .xap:application/x-silverlight-app

Page 8: IEDOTNETUG Silverlight Class Week 4

AppManifest.Xaml<Deployment xmlns=http://schemas.microsoft.com/client/2007/deployment xmlns:x=“http://schemas.microsoft.com/winfx/2006/xaml”

EntryPointAssembly=“UriStyles” EntryPointType=“UriStyles.App” RuntimeVersion=“4.0.50401.0”>

<Deployment.Parts> <AssemplyPart xname=“UriStyles”

Source=“UriStyles.dll” />

<AssemplyPart xname=“Systems.Windows.Controls.Data” Source=“Systems.Windows.Controls.Data.dll” />

</Deployment.Parts>

</Deployment>

Page 9: IEDOTNETUG Silverlight Class Week 4

Application Library Caching• Package shared assemblies separately

– Exploit browser caching

<Deployment xmlns=http://schemas.microsoft.com/client/2007/deployment xmlns:x=“http://schemas.microsoft.com/winfx/2006/xaml”

EntryPointAssembly=“UriStyles” EntryPointType=“UriStyles.App” RuntimeVersion=“4.0.50401.0”><Deployment.Parts> <AssemplyPart xname=“UriStyles”

Source=“UriStyles.dll” /></Deployment.Parts><Deployment.ExternalParts> <ExtensionPart Source=“Systems.Windows.Controls.Data.zip” /></Deployment.ExternalParts>

</Deployment>

Page 10: IEDOTNETUG Silverlight Class Week 4

Resources: XAP vs ‘Loose’• Images, Media, etc. in Silverlight projects end

up in XAP:– Application is self contained– Availability guaranteed once application starts

• Can add to Web site instead– Faster startup– Easier to change

Page 11: IEDOTNETUG Silverlight Class Week 4

Resources and URIs

• Image ad MediaElement refer to resources

• Absolute ‘pack:’ URI not supported

URI Style LocationImg.jpg In Xap (falls back to site, relative

to .xap location)/Img.jpg In DLL as embedded resource

(alsofalls back to site)

/AssemblyName;component/Img.jpg In Xap (falls back to site, relative to .xap location)

http://example.com/app/Img.jpg Specified Location

Page 12: IEDOTNETUG Silverlight Class Week 4

Download UI• Define as Xaml

• Set SplashScreenSource <param>

• Optionally handle onSourceDownloadProgressChanged– V1 programming model - JavaScript