From today's development, we start a new journey, the next lesson we should be familiar with the initiator and selector, in fact, the two are the same, there is no fundamental difference, the initiator has returned results, such as open search application to search, and the selector is the return content, such as select a picture.
So, what are starters and selectors? In fact, we can easily understand, plainly speaking, is to use the system comes with components or applications. Right, that's it, I said, sometimes a lot of concepts are just scary names, actually used is very simple, such as this launcher and selector.
In the end is not very simple, practice a little to know, this series of tutorials called "easy to get started", since it is easy to call, painful things will not call everyone to do, and MS has always focused on user experience, will not make everyone miserable.
To summarize, the use of initiators and selectors is the same way, are the following steps, but the selector because there is a return content, so there will be one more step.
One, the instantiation of the component, is the new one;
Second, set the relevant parameters or attributes, such as you want to call, you have to set a number, or you hit a bird ah;
Third, display application components, since the call to the System program, let the user operation, of course, show out;
Four, (optional) processing the return data, this is the selector.
Today, the first component, Bingmapsdirectionstask, is to launch Bing Maps to locate the driving route, yes, like the navigation system?
There are two ways to use the launcher, one is to start and end the tag, that is, from where to where, such as from Wuhan to Shanghai, then the start tag is Wuhan, the end tag is Shanghai, the other way is to start and end position, such as longitude, latitude and so on.
First, let's demonstrate the simple, tabbed navigation.
The interface is very simple, I believe that through the previous study, we all know how to get, as long as you can enter the start and end tag.
Here is the background C # code:
- Using System;
- Using System.Collections.Generic;
- Using System.Linq;
- Using System.Net;
- Using System.Windows;
- Using System.Windows.Controls;
- Using System.Windows.Documents;
- Using System.Windows.Input;
- Using System.Windows.Media;
- Using System.Windows.Media.Animation;
- Using System.Windows.Shapes;
- Using Microsoft.Phone.Controls;
- Using Microsoft.Phone.Tasks;
- Namespace Launchersample
- {
- public partial class Mapbylabel:phoneapplicationpage
- {
- Public Mapbylabel ()
- {
- InitializeComponent ();
- }
- private void Button1_Click (object sender, RoutedEventArgs e)
- {
- Bingmapsdirectionstask map = new Bingmapsdirectionstask ();
- Map. Start = new Labeledmaplocation {Label = Txtlabelstart.text};
- Map. End = new Labeledmaplocation {Label = Txtlabelend.text};
- Map. Show ();
- }
- }
- }
Remember to introduce Microsoft.Phone.Tasks space, all the initiators and selectors are inside.
OK next, we'll use a method that can be positioned over longitude and latitude.
First, add a reference, right-click the reference in the project, add a reference, and select System.device, OK.
Then do a good job of the interface, the longitude and latitude to start with, and latitude and longitude of the ending position.
Then there's the code.
- Using System;
- Using System.Collections.Generic;
- Using System.Linq;
- Using System.Net;
- Using System.Windows;
- Using System.Windows.Controls;
- Using System.Windows.Documents;
- Using System.Windows.Input;
- Using System.Windows.Media;
- Using System.Windows.Media.Animation;
- Using System.Windows.Shapes;
- Using Microsoft.Phone.Controls;
- Introduce the following namespaces
- Using Microsoft.Phone.Tasks;
- Using System.Device.Location;
- Namespace Launchersample
- {
- public partial class Bingmapsample:phoneapplicationpage
- {
- Public Bingmapsample ()
- {
- InitializeComponent ();
- }
- private void Button1_Click (object sender, RoutedEventArgs e)
- {
- Bingmapsdirectionstask BT = new Bingmapsdirectionstask ();
- Start position
- Labeledmaplocation Locstart = new Labeledmaplocation ();
- Locstart.location = new GeoCoordinate (convert.todouble (Txtlatitudestart.text), convert.todouble ( Txtlongitudestart.text));
- End Position
- Labeledmaplocation locend = new Labeledmaplocation ();
- Locend.location = new GeoCoordinate (convert.todouble (Txtlatitudeend.text), convert.todouble (TxtLongitudeEnd.Text)) ;
- Setting properties
- Bt. Start = Locstart;
- Bt. End = Locend;
- Show launcher
- Bt. Show ();
- }
- }
- }
Windows phone Development (22): Initiator and selector bingmapsdirectionstask