Skip to main content

Microsoft Silverlight

Answered Question Silverlight RendererRSS Feed

(0)

ronnyk
ronnyk

Member

Member

3 points

6 Posts

Silverlight Renderer

Hi guys,

Does someone know how Visual Studio does its Silverlight rendering while editing the Page.xaml file for example?

I would like to know if there is a way to reproduce this scheme to adapt it for an other IDE (calling an Silverlight ActiveX component ??)

 

Regards,

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Re: Silverlight Renderer

Hello, you can host a Silverlight application in your own environment. But that can be a lot of work, and currently there're no samples... Have a look at http://msdn.microsoft.com/en-us/library/cc296246(VS.95).aspx if you wish.

 

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

ronnyk
ronnyk

Member

Member

3 points

6 Posts

Re: Silverlight Renderer

OK, it seems to be very painful this way...

 Other Question so : How can I Load an xaml file in an html page just like the earlier version of Silverlight would allow to do :

Assume that I have Sphere.xaml with the following code :

<Canvas
 xmlns="http://schemas.microsoft.com/client/2007"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 Width="300" Height="300"
 Background="White"
 >

  <Canvas.Resources>
    <Storyboard x:Name="growAnimation">
      <DoubleAnimation
        Storyboard.TargetName="ellipse"
        Storyboard.TargetProperty="(Ellipse.Width)"
        To="250" Duration="0:0:2" />
      <DoubleAnimation
        Storyboard.TargetName="ellipse"
        Storyboard.TargetProperty="(Ellipse.Height)"
        To="250" Duration="0:0:2" />
    </Storyboard>
    <Storyboard x:Name="shrinkAnimation">
      <DoubleAnimation
        Storyboard.TargetName="ellipse"
        Storyboard.TargetProperty="(Ellipse.Width)"
        To="200" Duration="0:0:2" />
      <DoubleAnimation
        Storyboard.TargetName="ellipse"
        Storyboard.TargetProperty="(Ellipse.Height)"
        To="200" Duration="0:0:2" />
    </Storyboard>
  </Canvas.Resources>

  <Ellipse Width="200" Height="200" x:Name="ellipse" Canvas.Left="47" Canvas.Top="41">
    <Ellipse.Fill>
      <RadialGradientBrush GradientOrigin="0.75,0.25" Center="0.5,0.5"
     RadiusX="0.5" RadiusY="0.5">
        <GradientStop Color="Yellow" Offset="0" />
        <GradientStop Color="Green" Offset="1" />
      </RadialGradientBrush>
    </Ellipse.Fill>
  </Ellipse>

  <TextBlock x:Name="titleText" Width="200" Height="24" Canvas.Left="94" Text="Hello World" />
 <Button Content="Click"/>
</Canvas>

 and my page.html :

<!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" >
<!-- saved from url=(0014)about:internet -->
<head>
    <title>Silverlight Project Test Page </title>

    <style type="text/css">
    html, body {
     height: 100%;
     overflow: auto;
    }
    body {
     padding: 0;
     margin: 0;
    }
    #silverlightControlHost {
     height: 100%;
    }
    </style>
   
    <script type="text/javascript">
        function onSilverlightError(sender, args) {
       
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;
           
            var errMsg = "Unhandled Error in Silverlight 2 Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError")
            {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError")
            {          
                if (args.lineNumber != 0)
                {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
    </script>
</head>

<body>
    <div id="silverlightControlHost">
  <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" width="100%" height="100%">
   <param name="source" value="Sphere.xaml"/>
   <param name="onerror" value="onSilverlightError" />
   <param name="background" value="white" />
   
   <a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;">
        <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
   </a>
  </object>
  <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
    </div>

</body>
</html>

 

This actually works but now I have an xaml with UserControl and it won't work. I need to find a way to render only an xaml page and not the whole project within the XAP

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: Re: Silverlight Renderer

Can you post some code about you UserControl? Anyway, you can't use code behind unless you use xap...

 

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

ronnyk
ronnyk

Member

Member

3 points

6 Posts

Re: Re: Silverlight Renderer

ok we have tricked the way to reproduce a silverlight viewer using some filtering and some javascript codes (using downloader and createfromxamldownloader

but still there's a lot of constraint because it does not support some schemas like event attribute

 

Thanks anyway guys

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities