Windows phone Development (22): Initiator and selector bingmapsdirectionstask

Source: Internet
Author: User

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:

  1. Using System;
  2. Using System.Collections.Generic;
  3. Using System.Linq;
  4. Using System.Net;
  5. Using System.Windows;
  6. Using System.Windows.Controls;
  7. Using System.Windows.Documents;
  8. Using System.Windows.Input;
  9. Using System.Windows.Media;
  10. Using System.Windows.Media.Animation;
  11. Using System.Windows.Shapes;
  12. Using Microsoft.Phone.Controls;
  13. Using Microsoft.Phone.Tasks;
  14. Namespace Launchersample
  15. {
  16. public partial class Mapbylabel:phoneapplicationpage
  17. {
  18. Public Mapbylabel ()
  19. {
  20. InitializeComponent ();
  21. }
  22. private void Button1_Click (object sender, RoutedEventArgs e)
  23. {
  24. Bingmapsdirectionstask map = new Bingmapsdirectionstask ();
  25. Map. Start = new Labeledmaplocation {Label = Txtlabelstart.text};
  26. Map. End = new Labeledmaplocation {Label = Txtlabelend.text};
  27. Map. Show ();
  28. }
  29. }
  30. }


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.

  1. Using System;
  2. Using System.Collections.Generic;
  3. Using System.Linq;
  4. Using System.Net;
  5. Using System.Windows;
  6. Using System.Windows.Controls;
  7. Using System.Windows.Documents;
  8. Using System.Windows.Input;
  9. Using System.Windows.Media;
  10. Using System.Windows.Media.Animation;
  11. Using System.Windows.Shapes;
  12. Using Microsoft.Phone.Controls;
  13. Introduce the following namespaces
  14. Using Microsoft.Phone.Tasks;
  15. Using System.Device.Location;
  16. Namespace Launchersample
  17. {
  18. public partial class Bingmapsample:phoneapplicationpage
  19. {
  20. Public Bingmapsample ()
  21. {
  22. InitializeComponent ();
  23. }
  24. private void Button1_Click (object sender, RoutedEventArgs e)
  25. {
  26. Bingmapsdirectionstask BT = new Bingmapsdirectionstask ();
  27. Start position
  28. Labeledmaplocation Locstart = new Labeledmaplocation ();
  29. Locstart.location = new GeoCoordinate (convert.todouble (Txtlatitudestart.text), convert.todouble ( Txtlongitudestart.text));
  30. End Position
  31. Labeledmaplocation locend = new Labeledmaplocation ();
  32. Locend.location = new GeoCoordinate (convert.todouble (Txtlatitudeend.text), convert.todouble (TxtLongitudeEnd.Text)) ;
  33. Setting properties
  34. Bt. Start = Locstart;
  35. Bt. End = Locend;
  36. Show launcher
  37. Bt. Show ();
  38. }
  39. }
  40. }


Windows phone Development (22): Initiator and selector bingmapsdirectionstask

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.