Skip to main content

Microsoft Silverlight

Answered Question Need Urgent Help!!RSS Feed

(0)

jiaa1985
jiaa1985

Member

Member

5 points

9 Posts

Need Urgent Help!!

Hi Folks, I am a new bee in silverlight. I want to use an silverlight animated banner for my website which was in flash earlier. I got the xaml file converted from swf file and now i have silverlight .xaml file.How can i embed that silverlight xaml into my webpage so that it starts working !! Please Help !!

jay nanavati
jay nana...

Contributor

Contributor

3388 points

624 Posts

Re: Need Urgent Help!!

if your codebehind file is like Page.xaml.js means Javascript (Silverlight 1.0) than this code will work to embedd that.

<script type="text/javascript">
        function createSilverlight()
        {
            var scene = new SilverlightSite1.Page();
            Silverlight.createObjectEx({
                source: "Page.xaml",
                parentElement: document.getElementById("silverlightControlHost"),
                id: "SilverlightControl",
                properties: {
                    width: "100%",
                    height: "100%",
                    version: "1.0"
                },
                events: {
                    onLoad: Silverlight.createDelegate(scene, scene.handleLoad),
                    onError: function(sender, args) {
                        var errorDiv = document.getElementById("errorLocation");
                        if (errorDiv != null) {
                            var errorText = args.errorType + "- " + args.errorMessage;
                                   
                            if (args.ErrorType == "ParserError") {
                                errorText += "<br>File: " + args.xamlFile;
                                errorText += ", line " + args.lineNumber;
                                errorText += " character " + args.charPosition;
                            }
                            else if (args.ErrorType == "RuntimeError") {
                                errorText += "<br>line " + args.lineNumber;
                                errorText += " character " +  args.charPosition;
                            }
                            errorDiv.innerHTML = errorText;
                        }   
                    }
                }
            });
        }


        if (!window.Silverlight)
            Silverlight = {};

        Silverlight.createDelegate = function(instance, method) {
            return function() {
                return method.apply(instance, arguments);
            }
        }
    </script>
If it is not the case, can you explain in more detail. perhaps share that xaml.

Jay K Nanavaty
www.technologyopinion.com
Mark as answer if it helps. It will also help others...

milind.soman
milind.s...

Member

Member

389 points

72 Posts

Answered Question

Re: Need Urgent Help!!

First of all, let me clear that animations created through action script will not get exported in xaml; (Preferably this conversion should be done with static UI) You would have to code them again. I hope you have Visual Studio 2008 & Blend 2 installed on your machine. Follow these steps now:

  1. Go to Visual studio create a new silverlight project,
  2. Open the page.xaml & paste the converted XAML code in this page.xaml file, within <Grid></Grid> tags.
  3. Right click on page.xaml file in solution explorer & say 'Open In Blend'
  4. In design view check if everything looks ok as it was in flash.
  5. Do your coding in c# file to make animations work.
  6. Build the project by pressing F5. This will create a .xap file which you will host on your server
  7. Call the xap file instead of swf file.

This is very high level process, you may have to do some rework to get exact UI & experience.

Please "Mark as Answer" if this answered your question.

Sr. User Experience Consultant
SpadeWorx Software Services,
Pune, India.

jiaa1985
jiaa1985

Member

Member

5 points

9 Posts

Re: Need Urgent Help!!

Thanks Milind !! I followed steps said by you and got my silverlight control running as good as it was in flash. Thank you very much indeed!! jay nanavati Thanks for your post.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities