Calling one XAML file into another
Last post 05-06-2008 2:32 PM by gjhdigital. 1 replies.
Sort Posts:
05-06-2008 1:31 AM
Calling one XAML file into another

 

1)      I have not been able to find a  way to call one XAML file into another XAML file without replacing the previous one. In flash, for example, the main swf file can call different swf files. Is there any way we can do this for Silverlight?

 

vaishalim

Joined on 05-06-2008
Mumbai
Posts 6
05-06-2008 2:32 PM
Marked as Answer
Re: Calling one XAML file into another

Assuming you have page1.xaml and page2.xaml, and a javascript file

you would use the downloader object to call you 2nd xaml file, then use the CreatefromXaml() method to add it into your main canvas on page1.xaml

javscript would be something like this:

//page1.xaml main canvas has a loaded="downloadPage2Xaml"

function downloadPage2Xaml (sender, eventArgs)
 {
     var downloader = this.control.createObject("downloader");
     downloader.addEventListener("completed", Silverlight.createDelegate(this, this.downloadPage2rCompleted));    
     downloader.open("GET", "page2.xaml");
     downloader.send();    
 }

 function downloadPage2Completed (sender, eventArgs)
 {
     var xamlHeader    = sender.getResponseText("");
     this.rootHeader.children.clear();
     var header        = this.control.content.createFromXaml(xamlHeader, true);
     this.rootHeader.children.add(header);
 }

Greg
www.GJHDigital.com

gjhdigital

Joined on 12-25-2005
Posts 203