Silverlight: the XAML ASP.NET control and embeded XAML

Even though the Xaml”s XamlUrl porperty seems to indicate that it can only load XAML from an existing url, the truth is that you can also pass it a reference to a XAML excerpt which is embeded on the page. here”s a quick example of how you can do this:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default2.aspx.cs” Inherits=”Default2″ %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
    <title>Untitled Page</title>
</head>
<body>
    <script type=”text/xaml” id=”xamlContent”>
      <Canvas
        x:Name=”parentCanvas”
        xmlns=”http://schemas.microsoft.com/client/2007
        xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml
        Width=”640″
        Height=”480″
        Background=”Wheat”>
        <TextBlock
          Canvas.Left=”20″
          FontSize=”24″
          Text=”Hi”/>
      </Canvas>
    </script>

    <form id=”form1″ runat=”server”>
    <asp:ScriptManager runat=”server” ID=”manager” />
    <div>
        <asp:Xaml runat=”server”
            Height=”400″
            Width=”600″
            XamlUrl=”#xamlContent”
            ID=”myXaml” ></asp:Xaml>
    </div>
    </form>
</body>
</html>

Advertisements

~ by Luis Abreu on July 25, 2007.

2 Responses to “Silverlight: the XAML ASP.NET control and embeded XAML”

  1. Have you tried this in Firefox? (hint: remove the DOCTYPE…)

  2. honestly: no šŸ™‚ as always, you”re right.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: