Silverlight / WPF - Two Xaml page

Asked By Ritu Rani
03-May-11 12:39 AM
Hi,
I want to show two silverlight control on single aspx page. How i can do this..
  James H replied to Ritu Rani
03-May-11 12:55 AM

You need to create two Silverlight project and do like this:

In WebForm1:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="ClientBin/SilverlightApp1.xap"/>

In WebForm2

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="ClientBin/SilverlightApp2.xap"/>

both page1.xaml and page2.xaml control on either webform1.aspx or webform2.aspx

A solution is that let page1 contains the page2 so that both page1.xaml and page2.xaml control on either webform1.aspx or webform2.aspx.

 

Hope this helps.

 

  Riley K replied to Ritu Rani
03-May-11 12:57 AM
<table>
      <tr>
        <td style="height: 100%;">
          <div style="height: 100%;">
            <asp:Silverlight ID="Xaml1"  InitParameters="Control=TestSilverlight.Page" runat="server" Source="~/ClientBin/TestSilverlight.xap"
              MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
          </div>
        </td>
        <td>
          <div style="height: 100%;">
            <asp:Silverlight ID="Xaml2" InitParameters="Control=TestSilverlight.Page2" runat="server" Source="~/ClientBin/TestSilverlight.xap"
              MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
          </div>
        </td>
      </tr>
    </table>
  Ravi S replied to Ritu Rani
03-May-11 12:58 AM
HI

 In the hosting aspx page:
<div>
<asp:Silverlight ID ="silverlight1" runat="server" Height="210px" MinimumVersion="2.0" Source="~/ClientBin/SilverlightApplication1.xap"
    Width="244px" InitParameters="StartPage=page"></asp:Silverlight>
</div>
<div>

<asp:Silverlight ID ="silverlight2" runat="server" Height="210px" MinimumVersion="2.0" Source="~/ClientBin/SilverlightApplication1.xap"
    Width="244px" InitParameters="StartPage=NonDefaultStartPage"></asp:Silverlight>
</div>

in App.xmal.cs:
private void Application_Startup(object sender, StartupEventArgs e)
      {

        if (!e.InitParams.ContainsKey("StartPage"))
        {
          this.RootVisual = new Page();
        }
        else
        {
          switch (e.InitParams["StartPage"])
          {
            case "Page":
              this.RootVisual = new Page();
              break;
            case "NonDefaultStartPage":
              this.RootVisual = new Page1();
              break;
            default:
              throw new Exception("/StartPage must be 'Page' or 'NonDefaultStartPage'.");
          }
        }
      }


hope it helps you...
  Vickey F replied to Ritu Rani
03-May-11 12:59 AM

you may add the same xap in both the aspx pages and you will get the sme content at both the places.

you will have to add object tag in the aspx page that would hold the xap,

 
<div id="silverlightControlHost">

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/your.xap"/> <param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="3.0.40818.0" /> <param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/> </a></object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>

</div>



Foe more detail  follow this-
http://forums.silverlight.net/forums/p/191428/462846.aspx
  Vickey F replied to Ritu Rani
03-May-11 01:10 AM
One more solution for this is-

use the "InitParameters" attribute of <asp:Silverlight> tag. In this attribute we will give the key value pairs . In appStartup we will put a Switch Case statement in which we can match the value of InitParameters , the value will be the name of the xmal which we want to load .... below is the code sinnept-

<div> 

<asp:Silverlight ID ="silverlight1" runat="server" Height="210px" MinimumVersion="2.0" Source="~/ClientBin/SilverlightApplication1.xap"
    Width="244px" InitParameters="StartPage=page"></asp:Silverlight>

</div>

<div>

 <asp:Silverlight ID ="silverlight2" runat="server" Height="210px" MinimumVersion="2.0" Source="~/ClientBin/SilverlightApplication1.xap"
    Width="244px" InitParameters="StartPage=NonDefaultStartPage"></asp:Silverlight>

</div>

 

in App.xmal.cs:

private void Application_Startup(object sender, StartupEventArgs e)
      {

        if (!e.InitParams.ContainsKey("StartPage"))
        {
          this.RootVisual = new Page();
        }
        else
        {
          switch (e.InitParams["StartPage"])
          {
            case "Page":
              this.RootVisual = new Page();
              break;
            case "NonDefaultStartPage":
              this.RootVisual = new Page1();
              break;
            default:
              throw new Exception("/StartPage must be 'Page' or 'NonDefaultStartPage'.");
          }
        }
      }

Use this code hope this will help you.

 
  Ritu Rani replied to Ravi S
03-May-11 01:14 AM
hi,
I am not getting the tag <asp:silverlight id.....
It generates the error what i have to do to add this tag in aspx page.
  Ritu Rani replied to Vickey F
03-May-11 01:16 AM
Hi,
I am not getting the <asp:Silverlight> tag.
plz help..
  Vickey F replied to Ritu Rani
03-May-11 01:25 AM
Make sure you have installed the following.

  1. SL 2 runtime
  2. SL 2 SDK
  3. SL 2 Tool for VS 2008
  4. ASP.NET 3.5 ext
  Ritu Rani replied to Vickey F
03-May-11 01:31 AM
Hi,
I am working with vs2010
  Ravi S replied to Ritu Rani
03-May-11 01:50 AM
HI

k..then refer the following steps





 
We'll name the project "Silverlight1". When we click the "OK" button Visual Studio will prompt us with an additional dialog that allows us to choose whether we want to create just a Silverlight Application project, or optionally also add a server-side ASP.NET Web project to our solution to host the Silverlight Application within. For this sample we'll choose to add an ASP.NET Web Application project to the solution as well and name it "Silverlight1.Web". When we click "ok" Visual Studio will create a solution for us that has both a Silverlight client application and an ASP.NET web server application in it:



When we do a "build" Visual Studio will automatically copy the compiled Silverlight application to our web server project (no manual step or configuration required). The default web server project that VS created for us contains both an ASP.NET page (Silverligh1TestPage.aspx ) and a static HTML page (Silverligh1TestPage.html) that we can use to run and test our Silverlight Application within.




By default a newly created Silverlight application project contains a Page.xaml and App.xaml file, as well as code behind class files (which can be written in VB, C#, Ruby or Python) that are associated with them:

Page.xaml  > Page.xaml.cs

App.xaml  > App.xaml.cs



When we build our project, Visual Studio will by default compile the code and .XAML markup into a standard .NET assembly file, and then package it and any static resources (like images or static files we want to include in it) into a  ClientBin/Silverlight1.xap



".xap" files (pronounced "zap") use the standard .zip compression algorithm to minimize client download size.

To host and run a Silverlight 2 application, you can add an < object > tag into any standard HTML page (no JavaScript required) that points to the .xap file. Silverlight will then automatically download the .xap file, instantiate it, and host it within that HTML page in the browser.

Silverligh1TestPage.html

SL2



Silverligh1TestPage.aspx

SL2


refer the link
http://silverlight.aspxcode.net/Creating-New-Silverlight-VS2010-VC.aspx

hope it helps you...
  Vickey F replied to Ritu Rani
03-May-11 02:02 AM
Follow these link-

http://forums.silverlight.net/forums/t/11943.aspx

Here you will get some solutions for your problem.
  Vickey F replied to Ritu Rani
03-May-11 02:03 AM
Have you added this line in your page-

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>


Add this line and try.
  Shakti Maan replied to Ritu Rani
03-May-11 02:18 AM
First download System.Web.Silverlight.dll
and yes mujhe bhi provide karna. after downloading it.. ok

Create New Account
help
irolog.free.fr _ __ __ __ __ __ __ __ __ __ __ __ . . VB.NET - French Discussions Microsoft.VisualBasic.FileIO.SpecialDirectories (1) SHGetSpecialFolderPathA (1) Visual Studio (1) SHGetSpecialFolderPath (1) StartupEventArgs (1) SpecialDirectories (1) DllImport (1) NetworkAvailabilityChanged (1) Le moyen le plus simple est d'utiliser ce quie te porpose Visual Studio. Dans les propriétés du projet, onglet "application", y'a une case Il te suffit de Class MyApplication Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup ' d?clench? au d?marrage de l'application avant la cr?ation
Object Model. I will also show how to use the new SharePoint 2010 tools in Visual Studio 2010 to package the Silverlight application for deployment. Note that I will not be getting SharePoint Silverlight web part as shown below: Silverlight Web Part Next, we will create the Visual Studio 2010 solution. 4) Create a new Visual Studio project, selecting the Empty SharePoint Project template ( Visual C# | SharePoint | 2010 | Empty SharePoint Project ). Name your solution SharePointSolutionDeployment . This will also add an you find you really need to do otherwise. 5) Next, add a Silverlight Application project ( Visual C# | Silverlight | Silverlight Application ) to the solution. I named mine Simple Silverlight Application . 6) Change
Application_Exit" public partial class App : Application { public static MyServiceClient server; private void Application_Startup (object sender, StartupEventArgs e) { server = new MyServiceClient (); server.Open (); } private void Application_Exit (object sender, ExitEventArgs e) { server.Close call any method, it never arrives to the server side (tested in debug mode in Visual Studio with breakpoints), it seems the call is being "lost". Observing the ServiceHost on the server, it never goes to Faulted state, C# Discussions Visual Studio (1) StartupEventArgs (1) RoutedEventArgs (1) TimeoutException (1) ShutdownMode (1) ServiceHost (1) WCF (1) WPF (1) This is
ideas? .NET Framework Discussions ShutdownMode.OnExplicitShutdown (1) Application.Current.Shutdown (1) System.Windows.Forms (1) StartupEventArgs (1) Application.ShutdownMode (1) ShutdownMode (1) EventArgs (1) WPF (1) On 3 oct, 05:06 Hi All, Here is a new development. I decided to create a dummy project in visual studio to verify that it was not my code causing this issue. It still happens in is the app.xaml.cs public partial class App : Application { private void Application_Startup(object sender, StartupEventArgs e) { Window1 window = new Window1(); window.Show(); Window1 window2 = new Window1(); window2.ShowDialog(); Window1 window3 Hi All, Here is a new development. I decided to create a dummy project in visual studio to verify that it was not my code causing this issue. It still happens in is the app.xaml.cs public partial class App : Application { private void Application_Startup(object sender, StartupEventArgs e) { Window1 window = new Window1(); window.ShowDialog(); Window1 window2 = new Window1(); window2.ShowDialog(); Window1 window3 For example, in your Application sub-class ("App" by default): private void App_Startup(object sender, StartupEventArgs e) { Window dialog = new Dialog1(); ShutdownMode = ShutdownMode.OnExplicitShutdown; if (dialog.ShowDialog() = = true) { Window window = new