Windows Phone development (22): starter and selector-bingmapsdirectionstask to: http://blog.csdn.net/tcjiaan/article/details/73

Source: Internet
Author: User

Starting from today's development, we have started a new journey. We need to familiarize ourselves with the starters and selectors in the next course. In fact, they are the same and there is no fundamental difference between them, the starter has returned results. For example, if you open the search application to search, and the selector has returned content, select a photo.

 

So what are the starters and selectors? In fact, we can simply understand it. To put it bluntly, we use the built-in components or applications. That's right. As I said, sometimes many concepts are just names that are scary. Actually, they are very simple to use, such as the starter and selector.

 

Is it very easy? I will know it in practice. This series of tutorials is called "easy getting started". Since it is easy, it won't be difficult for everyone to do things. MS has always paid attention to user experience, it won't make everyone suffer.

To sum up, the method of using the initiator and Selector is the same, but the selector has one more step because of the returned content.

1. instantiate a component, that is, a new component;

2. Set related parameters or attributes. For example, if you want to make a phone call, you must set a number. Otherwise, you may need to set a bird;

3. display the application components. Now that the system program is called for user operations, show them;

4. (optional) process the returned data, which is available in the selector.

 

Today, let's talk about the first component, bingmapsdirectionstask, which is to start Bing map to locate and search the route. Is it like a navigation system?

 

There are two ways to use this starter. One is through the start and end labels, that is, from where to where, such as from Wuhan to Shanghai, the start label is Wuhan, and the end label is Shanghai; another method is the start and end positions, such as longitude and latitude.

 

First, let's demonstrate how to use tags for navigation.

 

The interface is very simple. I believe that through the previous study, we all know how to get it done, as long as you can enter the start and end labels.

The following is the background C # code:

 

[CSHARP]View plaincopyprint?

  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 button#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 the Microsoft. Phone. Tasks space where all the starters and selectors are located.

 

 

 

Next, we can use the longitude and latitude to locate the problem.

 

First, add a reference, right-click "Reference" in the project, add a reference, and then select system. device. OK.

 

Then, complete the interface, as shown in the preceding figure, the longitude and latitude of the start point and the end point.

 

 

Then there is the code.

 

[CSHARP]View plaincopyprint?

  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 namespace
  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 button#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. // Set attributes
  34. Bt. Start = locstart;
  35. Bt. End = locend;
  36. // Display the Initiator
  37. Bt. Show ();
  38. }
  39. }
  40. }

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.