Passing Querystring Parameters to a Silverlight Control
November 1, 2009 by Nauman · Leave a Comment
The approach to passing Querystring parameters to a Silverlight 2.0 Control that works for me is pretty simple. We check for the presence of Querystrings in the app.xaml Application_Startup using the Silverlight HTML Bridge and pass those values to the page’s constructor.
APP.XAML ——————————–
private void Application_Startup(object sender, StartupEventArgs e)
{
int fid = HtmlPage.Document.QueryString["fid"] != null ?
int.Parse(HtmlPage.Document.QueryString["fid"].ToString()) : -1;
int pid = HtmlPage.Document.QueryString["pid"] != null ?
int.Parse(HtmlPage.Document.QueryString["pid"].ToString()) : -1;this.RootVisual = new InField.Grid(fid, pid);
}
GRID.XAML STARTUP PAGE ———————–
private int employeeID = 1;
private int postID = 1;public Grid(int _employeeID, int _postID)
{employeeID = _employeeID;
postID = _postID;InitializeComponent();
PopulateGrid();
editing = false;
}