Search code examples
wpfuriframenavigation-framework

How can I parse query string in WPF?


hi I have wpf application. I created a pop up that act as container of pages being called. the pop up has frame in which I just assign source for it to load. My prob is that I need to pass a query so I can retrieve it upon loading of the called page.

I have looked in google and most of the answers are saying use NavigationService.Navigate.CurrentSource.Query but the prob is Navigation is null when I use it.

activity flow: When btn clicked = it calls window pop up show with some parameters. pop up loads : selects which case to do according to passed param (see below). In the code below I want to pass the value x as query.

My code:

 case PopUpModule.GALContinuingEduHistory:
                string x = "hello";
                lblHeader.Text = "GAL Continuing Education History";
                frmContent.Source = new Uri ("../Forms/FileMaintenance/Mediator/ContinuingEducHistoryPopUp.xaml?value=x",           UriKind.RelativeOrAbsolute);
                break;

Now my prob is how do I parse it when ContinuingEducHistoryPopUp.xaml loads?

thanks


Solution

  • To use the Navigation framework, you should use:

    frmContent.Navigate(new Uri ("../Forms/FileMaintenance/Mediator/ContinuingEducHistoryPopUp.xaml?value=x",           UriKind.RelativeOrAbsolute);
    

    Note: you can also make use of UriMapper to have simpler Uris in code.