Windows Phone 7 tips (4)

Source: Internet
Author: User

1. Common Use of WebClient in Windows Phone 7CodeSegment:

 WebClient Twitter= NewWebClient ();

Twitter. downloadstringcompleted + = New Downloadstringcompletedeventhandler (twitter_downloadstringcompleted );
Twitter. downloadstringasync ( New Uri ( " Http://api.twitter.com/1/statuses/user_timeline.xml? Screen_name = " + Twitternamebox. Text ));

2. On Windows Phone 7ProgramWhen deactivated, we need to process the program's persistent data and transient data.

A. Save persistent data to isolatedstroage

B. Process application transient data in the deactivated event of APP. XAML. CS and save the application transient data to phoneapplicationservice. state.

C. Process page transient data in the onnavigatedfrom event on the page and save the page transient data to phoneapplicationpage. state.

3. For the XML data source obtained through WebClient, we can use LINQ to XML for convenient operations and obtain its attributes for binding.

 Xelement xmltweets=Xelement. parse (E. Result );

Twitterlist. itemssource = From tweet In Xmltweets. descendants ( " Status " ) Select New Twitteritem {message = Tweet. element ( " Text " ). Value };

4. When using LINQ to XML, pay attention to whether the returned XML data contains namespaces.

This is part of the returned XML data from the tweet search WP7 project. Note that the returned XML data contains namespaces.

 

You also need to add a namespace when using LINQ to XML to process data,Tweet search WP7 ProjectThe processing code is as follows:

If the returned data does not contain a namespace, for example


 

The processing code is as follows:

 

 
5. By default, no shortcut for navigatetoeventhandler is available in Visual Studio.

 

Select the menu bar --> tool ---> Option, find the keyboard node, and enter navigatetoeventhandler in the search box to find editorcontextmenus. xamleditor. navigatetoeventhandler, press the shortcut key Ctrl + G + T (you can define it yourself), and click assign

 

In this way, we can use the shortcut key Ctrl + G + T, and do not need to right-click to select to go to event processing. In fact, we can see that the shortcut key has been added to the right-click option.

 

6. Three red threads for Application Design in Windows Phone 7: personal, relevant, and connected

7. Get the screen in Windows phone7(From http://mxmxm.com)

Share a code to get the screen. However, because the program cannot run in the background, you can only get the code by buttons or menus and save the image in the album.
Public void capturescreen (Object sender, eventargs E)
{
Writeablebitmap BMP = new writeablebitmap (480,800 );
BMP. Render (App. Current. rootvisual, null );
BMP. invalidate ();

Memorystream stream = new memorystream ();
BMP. savejpeg (stream, BMP. pixelwidth, BMP. pixelheight, 0, 80 );
Stream. Seek (0, seekorigin. Begin );

Medialibrary library = new medialibrary ();
String filename = "screenshot _" + datetime. Now. tostring ("yyyy-MM-dd_hh: mm: SS ");
Library. savepicture (filename, stream );
Stream. Close ();
}

8. Shake our phone 7

vibratecontroller VIB = vibratecontroller. default;
VIB. start (timespan. frommilliseconds (100);

9. The resources of WPF resources include static resources and dynamic resources)The difference between them is:

The object or value of a static resource is determined after the first compilation, and cannot be modified afterwards. Dynamic resources are determined at run time. When it is really needed during running, the value is found in the resource target.

 

10. In Windows Phone 7, we only need to pay attention to static resources)

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.