Tips for switching user controls in Silverlight 2 applications

Source: Internet
Author: User
Tags silverlight

Summary

As you know, in Silverlight 2 applications, each application generates a XAP file, and only one starting user control can be set in each XAP file. If we have multiple user controls that need to be loaded in a different ASP.net page, the easiest way to do this is to set up a corresponding Silverlight project for multiple user controls, but there are many drawbacks, such as our style files that need to be copied across multiple projects.

Get ready

Now create a project structure as shown in the following illustration, we have three user controls in the Silverlight project: Contentpage, Defaultpage, MasterPage, which require different user controls to be displayed when different asp.net pages are loaded.

Ideas

This is not a difficult task to implement, we can use initparams this property, as shown in the following figure:

or specify initparameters through param in HTML:

This property is a dictionary<string,string> type, where we can set a series of key-value pair initialization parameters, separated by commas "." So our idea is simply to specify the starting user control in the asp.net page or HTML by initparameters, and then get the parameters in the Application_Startup event and set the RootVisual.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.