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)