Another Way of Passing Values Between Windows Phone 7 Pages
Join the DZone community and get the full member experience.
Join For FreeA View of Different Pages
If you are a Windows 7 phone owner, you may have noticed that your phone has different pages that you can engage with. This is intentional, of course, and allows for users of this phone to get access to exactly the information that they want at any time.
Developers look at this as somewhat of a challenge. They need to figure out how they can keep certain bits of information from page to page while transferring other bits, and it is all about what they think their users will need to see from page to page.
We have to admit that nothing about this is easy. There are many people who simply won't have the bandwidth or ability to get it all done. That said, it can be very rewarding for some people as they pull off the seemingly impossible. There are a lot of ways to look at the work that creators on the Windows 7 phone do, but few can argue that there aren't some amazing things happening on the system.
Another appropriate way for passing data from one page to another during the navigation is in setting up destination page properties (or variables) within the OnNavigatedFrom method of the source page.
OnNavigatedFrom method is called just before a page is no longer the active page in a frame. For example this method is called if you invoke NavigationService.Navigate method from a source page. Due to the fact that OnNavigatedFrom method accepts NavigationEventArgs as input parameter you have access to the destination page stored in Content property.
Sample
I have created two pages: Page1.xaml and Page2.xaml. Inside Page2 I have added a string property named Parameter. Inside Page1 (codebehind) I have overridden method OnNavigatedFrom for setting up Page2′s Parameter property.
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { Page2 page2Instance = e.Content as Page2; if (page2Instance != null) { page2Instance.Parameter = "value"; } }
Advantages
Probably one of advantages is that you don’t have to store values in a static context, but simply pass them from one page to another. That approach is great for a wizard when you have several pages in a row and you need to store only the final result after the wizard is completed.
Disadvantages
This approach cannot be applied to applications that can lose sensitive information during the suspend mode (Tombstoning), because when the system restores your application from suspend mode there is no way to call OnNavigatedFrom method to set destination page properties.
Changing the Default Home Page
The default home page that one has set on their Windows phone can be changed as necessary. Some people simply leave up the page that is already pre-set as the default when they get the phone out of the box, but not everyone wants to leave it on that.
If there is a page that you are more likely to jump to in the first place, then you need to consider getting that set up as your homepage instead of leaving it as-is. There are plenty of people who make the choice to switch it up like this, and there is nothing wrong with making that same choice for yourself as well.
Just make sure you know which page you want to get set up when you do so.
Allow For Magnifying of the Page
Coders should be careful to make sure they allow users to work within the system to make alterations to the code that they have put out. This may mean allowing them to modify certain aspects of the page in order to make it more useful to them. For example, it might be necessary to magnify the page in order to better see the text that is present on the screen.
It is a big deal for some users as they try to read everything that is typed out on the page. These are seemingly small things, but certain users will benefit greatly from the small modifications that they need to make in order to get everything just the way that they need it.
Adding Some Shortcuts
There are shortcuts that can help people get where they need to go without your app more easily. This will save them some time as they work through the ways that they are ultimately going to use your app. It makes a big difference, and it may save them mere seconds, but that is precious time on the Internet.
You need to make sure the shortcuts that you program into your app are done in such a way that makes sense for how it is supposed to operate. The shortcuts should help people get to the most important information within the app. Those shortcuts simply make it easier for people to get to the most important aspects of the app more quickly.
There isn't exactly a science to how you create your shortcuts. Rather, you should review the areas in your app that people seem to travel to the most. Those are the hotspots that you absolutely want to have shortcuts ready to go to.
People appreciate when the app developers behind their favorite apps have clearly examined their behavior and determined what they are most likely going to want out of the experience. When they see the shortcuts pop up that are obviously useful to them, they know that the developers have done their job properly.
Create Real Value
Everything that you add into the code of your app should create real value for the users. What does this mean? It means that there shouldn't be any aspect of your app that doesn't add something interesting to what you are doing for the people.
The more that you can add to the value that they get out of the app, the better. They are expecting you to really come through for them, and you need to show that you are listening.
The information that you place into your app is meant to be used by people for various aspects of their day-to-day life. Are you actually coming through for them and creating something that will enhance their ability to get things done or not?
If not, then you need to go back to the drawing board and make sure you are putting your efforts where they need to be put. You risk destroying the trust between yourself and the users of your app if you aren't going the extra mile to deliver something interesting to them.
Keep Pages Simple
Finally, you should try to keep pages as simple as possible. You don't want to have too many distractions on your page because it will only deter people from using your service. The simpler the pages, the better they are for users. It is a fact that they like to keep things simple because it means that they can just get at the information that matters the most to them.
If you make things overly complicated or add in too many bells and whistles, many users are going to get lost in the page. Try to keep it simple and straightforward in order to make it the best possible experience for your users every time. That is all that there is to making an experience that works for everyone.
Published at DZone with permission of Jevgeni Tšaikin. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments