Put the Silverlight control on asp.net

If I have two aspx pages in each of them, I want to put different silverlight elements (2 differents usercontol), what can I do? .. I have to add 2 silverlight projects with my asp.net site and insert a * into each page .xap content ..?

Thank.

+3
source share
1 answer

No, you can put both UserControls in one XAP if you want.

You must use initParams to select which will be displayed when the application loads.

Here is an example that I used in the past: -

private void Application_Startup(object sender, StartupEventArgs e)
{
  string pageName = "UserControl1";

  if (e.InitParams.ContainsKey("startPage"))
  {
     pageName = e.InitParams["startPage"];
  }

  Type pageType = Assembly.GetExecutingAssembly().GetType("SilverlightApplication1." + pageName);
  RootVisual = (UIElement)Activator.CreateInstance(pageType);

}

The list of parameters of your tag object will look like this: -

<param name="source" value="ClientBin/SilverlightApplication1.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<param name="initParams" value="startPage=UserControl2" />

Silverlight, , SL, , startPage.

XAP , , XAP .

+2

Source: https://habr.com/ru/post/1741095/


All Articles