Skip to main content

Microsoft Silverlight

internal script modelRSS Feed

(0)

slyi
slyi

Participant

Participant

826 points

255 Posts

internal script model

Hi All,
         In reading http://blogs.msdn.com/jaimer/archive/2007/05/07/sandboxing-silverlight-1-0-aka-the-internal-script-model.aspx , i found it possible to reference JS files without the need for script tags in your html, but the "code" or "x:code" propertry is not in javascript SDK http://msdn2.microsoft.com/en-us/library/bb188567.aspx  
Is there any documetation on it?

Im trying to figure out why the following works

<script id="inLineXamlContent"><?xml version="1.0"?>
<Canvas
   xmlns="http://schemas.microsoft.com/client/2007"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="onRootLoaded" >
<x:Code Source="./myjs.js" Type="application/x-jscript" />
<TextBlock Text="hello" x:Name="poptext"/>
</Canvas>
</script>
<div id="controlHost" ><object id="wpfe" type="application/ag-plugin" height="400" width="400" ><param name="Source" value="#inLineXamlContent"/><embed id="wpfe" type="application/ag-plugin" width="400" height="400" source="#inLineXamlContent" /></object>
</div>

But the format below wont work :-(

<x:Code Type="application/x-jscript" ><![CDATA[
function onRootLoaded(sender, eventArgs)
{
 var na;
 na= sender.findName("poptext");
 na.Text="JS Text";
}]]>
</x:Code>

Thanks

slyi

BTW: Is there any chance for furture versions, we could reference the xaml via <xml> tag, rather <script> tag for inline xaml, as many bloging engines eg: WL Space block the script tag.

eg:

<xml id="inLineXamlContent"><?xml version="1.0"?>
<Canvas
   xmlns="http://schemas.microsoft.com/client/2007"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="onRootLoaded" >
<TextBlock Text="hello" x:Name="poptext" />
</Canvas>
</xml>

WynApse
WynApse

Star

Star

8456 points

342 Posts

Silverlight MVP

Re: internal script model

Hi slyi...

This is pretty interesting, and I wonder if it will disappear in later versions, or if you've found something that was left out of the documentation.

In your first example above, you have Loaded="OnRootLoaded" and then this:

<x:Code Source="./myjs.js" Type="application/x-jscript" />

I assume that myjs.js contains the "OnRootLoaded" function?

If this is how this works, it may help me make quick additions to my animated menu ...

Thanks!

-Dave

Stay in the 'Light
Silverlight MVP
http://www.wynapse.com
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities