LA.NET [EN]

Jul 25

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>

2 comments so far

  1. Dave Reed
    10:34 pm - 7-25-2007

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

  2. luisabreu
    10:43 pm - 7-25-2007

    honestly: no 🙂 as always, you”re right.