Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

Archive for July 23rd, 2008

MicroSoft Australia Tech.ED 2008 Sessions

Posted by ken zheng on July 23, 2008

The session list is out for MicroSoft Australia Tech.ED 2008 Sessions, check it out to see which sessions are interesting to you.

https://aunz.msteched.com/au/public/sessions.aspx

Posted in Uncategorized | Tagged: | Leave a Comment »

Embedded Multiple Silverlight User Controls

Posted by ken zheng on July 23, 2008

Silverlight does not have the Page type, the term is currently used is RootVisual UserControl. RootVisual object is analogous to the root window in WPF and can only be set once for the lifetime of the app, and is effective once the Application’s Startup event is raised. But this not true, you can set RootVisual as many times you want. So Application_Startup can be used to call multiple Silverlight controls.

Create a Silverlight application in visual studio 2008
Add 3 new Silverlight controls and lets name them Header, Footer and Leftbar.
Now put some text in these controls so that they can be distinguished on the aspx page.

Call these control s in the Form of Testpageforsilverlightapplication and set the InitParameters.

Change the Application_Startup in App.xaml.cs as below.

private void Application_Startup(object sender, StartupEventArgs e)

{

if (e.InitParams.ContainsKey(“ControlId”))

{

switch (e.InitParams["ControlId"])

{

case “Header”:

this.RootVisual = new Header();

break;

case “Leftbar”:

this.RootVisual = new Leftbar();

break;

case “Footer”:

this.RootVisual = new Footer();

break;

}

}

}

Run the application and all the 3 controls can be seen on aspx page. If we put a breakpoint at Application_Startup and we can see that it is called as many times as there silverlight controls on aspx page.

Posted in Silverlight | Tagged: | Leave a Comment »