Fully embed a Silverlight application in an HTML page?

I'm still trying to solve the problem of displaying an image on a website without an external image. Since the data scheme does not work on older browsers or large images, I am currently experimenting with Silverlight.

I managed to solve the embedding using Base64 Encoding the Image and transfer it using InitParams, but in fact I just put off my problem: instead of an external image, I now have an external XAP file ...

Is there a way to take the XAP file and somehow embed it in HTML? Or, alternatively, can I use JavaScript-based Silverlight 1.1 in this situation? It is literally just displaying an image that has been transmitted as a string.

0
source share
1 answer

For what you are trying to do, it looks like you can look at Sam Ruby SVG with XAML backup , which displays SVG in browsers that support it and passes through Silverlight to IE.

You can embed XAML like this (source: MSDN ):

    <html>
    <head>
      <title>Display Date</title>
      <!-- Define Loaded event handler for TextBlock. -->
      <script type="text/javascript">
        function setDate(sender, eventArgs)
        {
          sender.text = Date();
        }
      </script>
    </head>

    <body bgcolor="Teal">

    <!-- Define XAML content. -->
    <script type="text/xaml" id="xamlContent"><?xml version="1.0"?>
      <Canvas
        xmlns="http://schemas.microsoft.com/client/2007"
        Background="Wheat">
        <TextBlock
          Canvas.Left="20"
          FontSize="24"
          Loaded="setDate" />
      </Canvas>
    </script>

    <div id="silverlightControlHost">
      <object type="application/x-silverlight" width="100%" height="100%" id="slc">
        <param 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>
    </html>

Please note that Firefox 2 had an error ( bugzilla 356095 ) that could not be used with XHTML DOCTYPE . I believe this can be fixed.

+1
source

All Articles