Inline XAML is the concept of a JavaScript API that is only available for Silverlight. Inline XAML is not compatible with Silverlight's managed APIs.
Using inline XAML
Because of its relationship to the browser DOM, inline XAML constitutes a thoughtful choice to use the JavaScript API. If you do not have a discrete XAML file that is understood by the managed project file (the file is specified in its root directory), the inline XAML solution cannot understand how to connect code-behind and XAML, and there is no specific directive to compile and connect managed code. x:class
To use inline XAML, you must include the XAML in a special <SCRIPT> block and specify "Text/xaml" as the Type property. The XML document type declaration <?xml version= "1.0"?> is located before the XAML content. The XAML content must be uniquely identified so that the Source initialization parameter of the Silverlight plug-in can reference it. The source parameter identifies the XAML content with the prefix "#" in the <SCRIPT> element, followed by the ID value. XAML content can also define events that reference event handlers on an HTML page.
The following HTML example shows how to create an inline XAML content. In this case, the HTML page contains both JavaScript and XAML content. Note the OBJECT element construction that specifies the source parameter.
Description
The <SCRIPT> element that contains inline XAML content must precede the HTML element that contains the Silverlight plug-in, which references the inline XAML for its source initialization.
<title>display date</title>
<!--Define Loaded event handler For TextBlock. -->
<script type= "text/javascript" >
function setdate (sender, EventArgs)
{
Sender.text = Date ();
}
</script>
<body bgcolor= "Teal" >
<!--Define XAML Co Ntent. -->
<script type= "Text/xaml" id= "xamlcontent" ><?xml version= "1.0"?>
<canvas
xmlns= "Htt" p://schemas.microsoft.com/client/2007 "
background=" wheat ">
<textblock
canvas.left="
fontsize=
loaded= "setdate"/>
</Canvas>
</script>
<div id= "Silverligh Tcontrolhost ">
<object type=" application/x-silverlight "width=" 100% "height=" 100% "id=" SLC ">
<pa Ram name= "source" value= "#xamlContent"/>
<param name= "onload" value= "onloaded"/>
<param Name= "Iswindowless" value= "true"/>
</object>
<iframe style= ' visibility:hidden;height:0;width:0 ; border:0px ' ></iframe>
</div>
</body>
When this page is displayed, it indicates that the Silverlight plug-in has been loaded and that a Loaded event has been raised for the TextBlock object, which causes TextBlock to display the current date and time