Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


SSWUG

Reader rating:
Article source: CoDe (2012 Mar/Apr)


Article Pages:  1  2 3 - Next >


Working with Windows Phone User Interfaces, Part 2

In Part 1 of this article you learned how to work with orientation changes on the Windows Phone and how to create horizontally scrolling pages using Panorama and Pivot pages. In Part 2 you’ll see how to interact with some of the built-in applications on the phone through the use of the Launcher and Chooser applications.

In addition, you will learn to create a common task bar for your Windows Phone using the Application Bar. This article assumes that you have Visual Studio 2010 and the Windows Phone tools installed along with it. You must download and install the Windows Phone tools separately to use them with Visual Studio 2010. You may also download the free Visual Studio 2010 Express for Windows Phone developer environment.

Launchers

The Windows Phone does not support multi-tasking (yet); however, you can interact with many of the built-in applications on the phone from within your application. You can interact with the built-in applications on the phone in two ways: passing in data, or get back data. A Launcher type of application lets you pass data from your application into the built-in phone application. In a Chooser type of application you will use a built-in phone application to select some data that is stored on your phone and return that data to your application.

"
The Windows Phone does not support multi-tasking (yet); however, you can interact with many of the built-in applications on the phone from within your application.
"

Using a Launcher

When you use the Launcher API on the Windows Phone, your application calls one of the built-in applications. The user will complete a task, and then control will return to your application. No data will be returned from a Launcher application; however, your application may pass in some data to the Launcher. As an example of using a Launcher, you might ask a user to input a phone number, and then you pass that phone number to the SavePhoneNumberTask as shown in Figure 1. If the user saves that phone number, a return result of OK will be returned, but no other data.

Click for a larger version of this image.

Figure 1: Enter a Phone Number and then call the SavePhoneNumberTask Launcher.

One important thing to keep in mind when using either the Launcher or Chooser API is that calling these applications could cause your application to be “tombstoned.” It will be your responsibility to restore any data that you want after your application is reactivated from the tombstoned state.

"
One important thing to keep in mind when using either the Launcher or Chooser APIs is that calling these applications could cause your application to be “tombstoned.”
"

Built-In Launchers

Windows Phone contains several built-in applications that your C# or Visual Basic code can launch by instantiating an instance of the appropriate class. You can find all of the Launcher classes in the Microsoft.Phone.Tasks namespace. The list below contains the Launcher classes you can use on the Windows Phone.

  • EmailComposeTask
  • MarketplaceDetailTask
  • MarketplaceHubTask
  • MarketplaceReviewTask
  • MarketplaceSearchTask
  • MediaPlayerLauncher
  • PhoneCallTask
  • SearchTask
  • SmsComposeTask
  • WebBrowserTask

To use any of the Launcher task classes, you first need to add a using statement at the top of your Page class.

using Microsoft.Phone.Tasks;

Next, you create a field in your Page class with a variable that will point to the specific Launcher you wish to use.

SavePhoneNumberTask _Task;

Now create an instance of the class in the constructor for your page and hook up the Completed event.

public LauncherPage()
{
  InitializeComponent();
      
  _Task = new SavePhoneNumberTask();
  _Task.Completed += new 
    EventHandler<TaskEventArgs>(_Task_Completed);
}

You must create the instance of the task and hook up the Completed event handler in the constructor because your application will be tombstoned once it calls the Launcher application. Upon reactivating your application, the constructor will be called again and the completed event needs to be hooked back up so the Launcher can call the event.

In Figure 1 the user is asked to put a phone number into a text box named “txtPhone” on this page. When you click on the Save Phone Number button the Click event will fire. At this point you take the value from the txtPhone.Text property and set the PhoneNumber property on the SavePhoneNumberTask object. Now you call the Show() method of the task object and the Launcher application will run and receive the phone number from your application. Once the new application is running, your application will be tombstoned.

private void Button_Click(object sender, 
RoutedEventArgs e)
{
  // Pass phone number into contacts
  _Task.PhoneNumber = txtPhone.Text;
  // Display contact info app
  // This WILL tombstone your app
  _Task.Show();
}

In the Completed event you will want to check the e.TaskResult to see if the user accomplished the task. For example, when saving a phone number, if they do not actually click the save button after adding the new phone number/contact, then the result will not come back as OK. Each Launcher may report different results depending on what each one is supposed to do. In the Completed event procedure below you will simply display a message box telling the user that the phone number was saved.

void _Task_Completed(object sender, TaskEventArgs e)
{
  if (e.TaskResult == TaskResult.OK)
    MessageBox.Show("Phone Number Saved");
}
&

By: Paul D. Sheriff

Paul D. Sheriff is the President of PDSA, Inc. (www.pdsa.com), a Microsoft Partner in Southern California. Paul acts as the Microsoft Regional Director for Southern California assisting the local Microsoft offices with several of their events each year and being an evangelist for them. Paul has authored several books, webcasts, videos and articles on .NET, SQL Server and SharePoint. You can reach Paul via email at PSheriff@pdsa.com or at Paul Sheriff’s Inner Circle (www.PaulSheriffInnerCircle.com).

PSheriff@pdsa.com



Article Pages:  1  2 3 - Next Page: 'Choosers' >>

Page 1: Working with Windows Phone User Interfaces, Part 2
Page 2: Choosers
Page 3: Application Bar

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3 out of 5

1 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      LearnNow

 

Sharepoint TechCon