开发者

silverlight "initparams", key value, cannot load value

开发者 https://www.devze.com 2023-01-30 12:33 出处:网络
have a initparams in html object: <param name=\"initParams\" value=\"location=images/images.xml\" />

have a initparams in html object:

<param name="initParams" value="location=images/images.xml" />

is it correct way to set location?

in MainPage.xaml.cs:

WebClient client = new WebClient();
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);

            client.DownloadStringAsync( new Uri(Location, UriKind.RelativeOrAbsolute));



 void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
        开发者_如何学C    string xml = e.Result;
            XDocument xDoc = XDocument.Parse(xml); 

in line string xml = e.Result flying TargetInvocationException.

has some any idea?


I am not sure what your are trying to achieve with the code you provided, but the only way to retrieve the initParams (as I know) is in the Application_Startup.

That function has a StartupEventArgs that contains the InitParams as a Dictionary.

So you can retrieve your parameter value using that code below :

private void Application_Startup(object sender, StartupEventArgs e)
{
   this.RootVisual = new SilverlightApplication4.foo.SilverlightControl1();

   String imageLocation = e.InitParams["location"];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消