WP7 weather forecast source code (four UI production) visual status

Source: Internet
Author: User

Previous section address: http://www.cnblogs.com/wildfeng/archive/2012/03/25/2416388.html

This lecture describes how to create controls in the city list.

This is a custom control. The layout is the same as the forecasttile Control described in the previous chapter, but the visual state is added based on it.

Added effects and curves for the three States.

TheCodeAs follows:

 
1:<Usercontrol
 
2:Xmlns =Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 
3:Xmlns: x =Http://schemas.microsoft.com/winfx/2006/xaml"
 
4:Xmlns: D =Http://schemas.microsoft.com/expression/blend/2008"
5:Xmlns: MC =Http://schemas.openxmlformats.org/markup-compatibility/2006"
 
6:MC: ignorable ="D"
 
7:X: class ="Weather. citytile"
 
8:D: designwidth ="184"D: designheight ="105">
 
9:<Usercontrol. Resources>
 
10:<Style X: Key ="Buttonstyle1"Targettype ="Button">
 
11:<Setter property ="Template">
12:<Setter. value>
 
13:<Controltemplate targettype ="Button">
 
14:<Grid X: Name ="Layoutroot"Background ="Transparent"Rendertransformorigin ="0.5, 0.5"> <! -- Center location of deformation -->
 
15:<Grid. rendertransform>
 
16:<Compositetransform/>
 
17:</Grid. rendertransform>
18:<Visualstatemanager. visualstategroups> <! -- Manager type. Status group -->
 
19:<Visualstategroup X: Name ="Commonstates">
 
20:<Visualstategroup. transitions> <! -- Visual transition, set the animation effect for different state switches in a single State group -->
 
21:<Visualtransition generatedduration ="0: 0: 1"To ="Pressed">
 
22:<Visualtransition. generatedeasingfunction>
23:<Backease easingmode ="Easeout"/>
 
24:</Visualtransition. generatedeasingfunction>
 
25:</Visualtransition>
 
26:<Visualtransition generatedduration ="0: 0: 1"To ="Normal">
 
27:<Visualtransition. generatedeasingfunction>
 
28:<Backease easingmode ="Easeout"/>
29:</Visualtransition. generatedeasingfunction>
 
30:</Visualtransition>
 
31:<Visualtransition generatedduration ="0: 0: 1"To ="Mouseover">
 
32:<Visualtransition. generatedeasingfunction>
 
33:<Backease easingmode ="Easeout"/>
 
34:</Visualtransition. generatedeasingfunction>
35:</Visualtransition>
 
36:</Visualstategroup. transitions>
 
37:<Visualstate X: Name ="Disabled"/> <! -- Set the animation effect of a single state -->
 
38:<Visualstate X: Name ="Normal"/> <! -- Set the animation effect of a single state -->
 
39:<Visualstate X: Name ="Mouseover"/> <! -- Set the animation effect of a single state -->
40:<Visualstate X: Name ="Pressed"> <! -- Set the animation effect of a single state -->
 
41:<Storyboard>
 
42:<Doubleanimation duration ="0"To ="0.8"Storyboard. targetproperty ="(Uielement. rendertransform). (compositetransform. scalex )"Storyboard. targetname ="Layoutroot"D: isoptimized ="True"/>
43:<Doubleanimation duration ="0"To ="0.8"Storyboard. targetproperty ="(Uielement. rendertransform). (compositetransform. scaley )"Storyboard. targetname ="Layoutroot"D: isoptimized ="True"/>
 
44:</Storyboard>
 
45:</Visualstate>
 
46:</Visualstategroup>
 
47:</Visualstatemanager. visualstategroups>
48:<Image Source ="/Weather; component/usercontrol/base.png"Stretch ="Fill"/>
 
49:<Image margin ="90,-14,0, 32"Source ="{Binding cityweathericon }"/>
 
50:<Textblock text ="{Binding citytemperature }"Fontsize ="20"Width ="100"Margin ="8, 8, 8"Horizontalalignment ="Stretch"Verticalalignment ="Bottom"/>
51:<Contentpresenter horizontalalignment ="Left"Height ="40"Margin ="8, 8, 0, 0"Verticalalignment ="TOP"/>
 
52:</GRID>
 
53:</Controltemplate>
 
54:</Setter. value>
 
55:</Setter>
 
56:<Setter property ="Fontsize"Value ="26"/>
57:<Setter property ="Foreground"Value ="White"/>
 
58:</Style>
 
59:</Usercontrol. Resources>
 
60:<Button name ="Cityname"Content ="{Binding cityname }"Style ="{Staticresource buttonstyle1 }"/>
 
61:</Usercontrol>

Because the number of controls in the city list is dynamically loaded from the data in the independent storage, the assignment code is as follows.

 
1:Private VoidAddcity (StringCityname,StringCitytemperature,StringWeathericonpath)
2:{
 
3:Citytiledata citydata =NewCitytiledata ();
 
4:Citydata. citytemperature = citytemperature;
 
5:Citydata. cityweathericon = weathericonpath;
 
6:Citytile city =NewCitytile ();
 
7:City. datacontext = citydata;
 
8:City. cityname. content = cityname;
 
9:City. width = 184;
 
10:City. Height = 105;
11:City. Margin =NewThickness (15, 10, 15, 10 );
 
12:Wrappanelcitylist. Children. Add (city );
 
13:City. cityname. Click + =NewRoutedeventhandler (cityname_click );
 
14:}
 
15: 
 
16:VoidCityname_click (ObjectSender, routedeventargs E)
 
17:{
18:Navigationservice. navigate (NewUri ("/Loading. XAML? Cityname ="+ (Button) sender). content +"& Andgopage = weatherview", Urikind. relativeorabsolute ));
 
19:}

After 20 days, I will graduate. It is really difficult to find a job now. There is no need for fresh graduates who have no work experience. I have been developing mobile phones for so long that I can't afford a smartphone. Nokia 168c has been following me for three years. It's really a tragedy ...... Work. I feel that the company is focusing on work experience, and the technology is not as good as having work experience. I want to talk about the ability of new graduates, and the ability to work for several years is not strong.

Author: QQ: 29992379

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.