However, For starters, I thought I would put down the steps quickly here
1. biggest change and where I struggled, How to create a parameter in ASP.NET page, the
2. in Code behind in ASPX, use this control to set the property on any event. 2 things to remember here, Use the ".Text" to set the key value pair like this.
Source.Text ="Param1="+ Param1.ToString();
3. In App.xaml.cs, in Application_Startup event, simply add 2 lines, and your total code should look like
this.RootVisual = new MainPage();
foreach (var data in e.InitParams)
this.Resources.Add(data.Key, data.Value);
4. In MainPage.xaml.cs you want to access this, Simply use following construct.
App.Current.Resources["Param1"].ToString();
Note - Create a Loaded even in MainPage.xaml otherwise we will get. Final code should look like
public MainPage()
{ InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{ string param 1 = App.Current.Resources["Param1"].ToString();
}
No comments:
Post a Comment