views:

261

answers:

1

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

I managed to solve the embedding by Base64 Encoding the Image and passing it in using the InitParams, but actually I just moved my problem away: Instead of an external Image, I now have an external XAP File...

Is there a way taking the XAP File and somehow embedding it in the HTML? Or alternatively, can I use the JavaScript-based Silverlight 1.1 in this situation? It's literally just displaying an image that has been passed in as a String.

+1  A: 

For what you're trying to do, it sounds like you might want to look at Sam Ruby's SVG with XAML fallback, which displays SVG in browsers which support it, and renders via Silverlight in IE.

You can inline 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>

Note that Firefox 2 had a bug (bugzilla 356095) which prevented using this with XHTML DOCTYPE. I believe this may be fixed.

Jon Galloway