Silverlight ASP.NET / HTML Pass Parameter 方法

 
Silverlight ASP.NET / HTML Pass Parameter 方法
 

   SilverlightApplication10TestPage.aspx
 
   <object>
      … …
      <param name="minRuntimeVersion" value="4.0.50826.0" />
      … …
      <param name="initParams" value="videourl=http://127.0.0.1:8134/vod/98.mp4" />
      … …
 

 

   App.xaml.cs
 
   private void Application_Startup(object sender, StartupEventArgs e)
   {
      if (e.InitParams.Count > 0 && e.InitParams["videourl"] != null)
      {
         this.RootVisual = new MainPage(e.InitParams["videourl"].ToString().Trim());
      }
      else
      {
         this.RootVisual = new MainPage("");
      }
   }
 

 

   MainPage.xaml
 
   public MainPage(String URL)
   {
 
      InitializeComponent();
 
      … …
 
      if(URL != null && URL != ""){
         this.mediaElement1.AutoPlay = true;
         this.mediaElement1.Source = new Uri(URL);
      }
 
      … …
 
   }