Windows Phone – Passing arguments between pages and Input Scope
On my serie of posts for developing on Windows Phone, today I would like to illustrate how I can pass arguments to page when navigating to it and apply input scope to reduce the input panel for specific input data format. Let’s start with passing argument to page before opening it. If you are Windows Form/WPF developer, you may use a property to get data for form before opening or loading it. This data will be provided to some pre-processing tasks before showing form to user. For example
Form1 f1 = new Form1(); f1.DataToBeSet = "Hihihaha"; f1.Show();
However in Silverlight or Windows Phone, there is no Show() or ShowDialog() function anymore. I can only navigate between page like following.
NavigationService.Navigate(new Uri("/WebPage.xaml", UriKind.Relative));
So then how can I pass argument for page before showing it to users. It is pretty simple, you just need to add some query arguments in Uri and get them back when the new page is loading as following
//On calling Page
NavigationService.Navigate(new Uri("/BrowsePage.xaml?RSSSource="+strSource, UriKind.Relative));
...
//On the BrowsePage side
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
try
{
...
string strRSSSource = "";
NavigationContext.QueryString.TryGetValue("RSSSource", out strRSSSource);
vmDatabase.GetRssItems(strRSSSource);
...
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
So you can see how I can pass argument RSSSource to BrowserPage.xaml.
InputScope
The next section in this post I would like to discuss about InputScope and input panel. In windows phone the Software Input Panel can not be customized anymore. Although you can not customize the input panel but you can adjust its view according to input context. For example if you mark a TextBox as requiring a TelephoneNumber you will get a numerical keypad . There are a number of different contexts supported which you can read here http://msdn.microsoft.com/en-us/library/system.windows.input.inputscopenamevalue%28VS.96%29.aspx . Some of typical InputScopeNameValue are listed below
- Password
- TelephoneNumber
- EmailNameOrAddress
- Maps
- NameOrPhoneNumber
- Url
…
To apply the input context for the text box, you just need to set the InputScope property to one of listed valued in link above to get a matched panel.
<TextBox InputScope="Url" Text="http://vnexpress.net/RSS/GL/trang-chu.rss" x:Name="txtURL" Margin="0,50,0,0" Height="71" VerticalAlignment="Top">
The differences of input panel between with and without setting InputScope you can see in example below.
| With InputScope | Without InputScope |
Update 07.04.2010: Remove some quotations cause of copyright.
Popularity: 3% [?]

[...] are a number of posts out there (such as this one) talking about the use of QueryString parameters as a way of passing information between pages in a [...]
[...] http://hintdesk.com/windows-phone-passing-arguments-between-pages-and-input-scope/ [...]
Leave your response!
Computer security »
Hacking – How to hack WPA/WPA2 Password with BackTrack through cracking WPS?
Last week I’ve read small news on c’t magazine saying that the default password of EasyBox router used for Vodafone, Telecom, Arcor in Germany … was hacked by Sebastian Petters. That means if someone is using default settings of EasyBox, you can get his WLAN password easily and then access his network. This default password was generated by a algorithm and this algorithm was patented. Therefore like other patents, the complete description of algorithm was …
Programming »
C# – Host Microsoft Chart in WPF application
How we provide our customers the way to display their data is a important feature of every software for data management. Maybe the users want to use Bar, Line, Pie, Pyramid chart… someone wants to display as 2D and the other wants 3D for his plotting. The financial prefer Kagi, Renko, Point and Figure chart… meanwhile the statisticians maybe use Bar and Column, Cylinder or just simple Line chart. Because of these numerously different requirements …
Tutorial »
Tools – Doidw – Do I DDos this website?
Last year I have seen a lot of DDOS attacks aimed to website of news or independent communities. These websites were attacked by a botnet built from unknown virus (which wasn’t detected by any antivirus at that time). Some professionals found some variants of this virus but the websites were still heavily attacked.
Some of professional users are willing to help to find more variants of this virus. They would like to check if computers of …
Donation
Archives
Blogroll
Tag Cloud
.net reactor 64 bit 2012 asp.net auto backtrack blog c# codeveil 3.x database Entertainment firefox game gold hack hacking master volume munich mvvm online notes password pet php picasa reverse engineering security sharepoint silverlight ssh theme tlbb tool trip visual studio wallpaper wcf web album webpart web service windows windows 7 windows phone word wpf yahoo messenger