今天把导航改成HubTile模式了,见图:
XAML:
代码语言:javascript复制<Grid x:Name="ContentPanel" Grid.Row="1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="10,0,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<toolkit:HubTile Grid.Row="0" Grid.Column="0"
Margin="12,12,0,0"
x:Name="HY" ManipulationCompleted="ManipulationCompleted"/>
<toolkit:HubTile Grid.Row="0" Grid.Column="1"
Margin="12,12,0,0"
x:Name="OM" ManipulationCompleted="ManipulationCompleted"/>
<toolkit:HubTile Grid.Row="1" Grid.Column="0"
Margin="12,12,0,0"
x:Name="RY" ManipulationCompleted="ManipulationCompleted"/>
<toolkit:HubTile Grid.Row="1" Grid.Column="1"
Margin="12,12,0,0"
x:Name="HanY" ManipulationCompleted="ManipulationCompleted"/>
<toolkit:HubTile Grid.Row="2" Grid.Column="0"
Margin="12,12,0,0"
x:Name="YY" ManipulationCompleted="ManipulationCompleted" />
<toolkit:HubTile Grid.Row="2" Grid.Column="1"
Margin="12,12,0,0"
x:Name="FAV" ManipulationCompleted="ManipulationCompleted" />
代码语言:javascript复制</Grid>
cs:读取所有频道第一首歌的专辑封面
代码语言:javascript复制1 public ChannelTile()
2 {
3 InitializeComponent();
4 TouchPanel.EnabledGestures = GestureType.Tap | GestureType.HorizontalDrag;
5 if (!PlayListHelper.IsInited)
6 {
7 PlayListHelper.InitChannelComplete = new Action(PlayListHelper_InitChannelComplete);
8 PlayListHelper.InitChannel();//初始化播放列表
9 }
10 }
11
12 /// <summary>
13 /// 初始化tile的image跟title
14 /// </summary>
15 void PlayListHelper_InitChannelComplete()
16 {
17 var list = PlayListHelper.GetEachChannel1stSong();//获取所有频道的第一首歌曲
18 var song = list.Where(s => s.channel == (int)ChannelType.华语).ToList();
19 if (song != null && song.Count > 0)
20 {
21 var s = song[0];
22 HY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
23 HY.Title = ChannelType.华语.ToString();
24 HY.Message=s.artist "-" s.title;
25 }
26 else
27 {
28 HY.Title = ChannelType.华语.ToString();
29 HY.Message = "No Song!";
30 }
31
32
33 song = list.Where(s => s.channel == (int)ChannelType.欧美).ToList();
34 if (song != null && song.Count > 0)
35 {
36 var s = song[0];
37 OM.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
38 OM.Title = ChannelType.欧美.ToString();
39 OM.Message = s.artist "-" s.title;
40 }
41 else
42 {
43 OM.Title = ChannelType.欧美.ToString();
44 OM.Message = "No Song!";
45 }
46
47
48 song = list.Where(s => s.channel == (int)ChannelType.韩语).ToList();
49 if (song != null && song.Count > 0)
50 {
51 var s = song[0];
52 HanY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
53 HanY.Title = ChannelType.韩语.ToString();
54 HanY.Message = s.artist "-" s.title;
55 }
56 else
57 {
58 HanY.Title = ChannelType.韩语.ToString();
59 HanY.Message = "No Song!";
60 }
61
62 song = list.Where(s => s.channel == (int)ChannelType.日语).ToList();
63 if (song != null && song.Count > 0)
64 {
65 var s = song[0];
66 RY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
67 RY.Title = ChannelType.日语.ToString();
68 RY.Message = s.artist "-" s.title;
69 }
70 else
71 {
72 RY.Title = ChannelType.日语.ToString();
73 RY.Message = "No Song!";
74 }
75
76 song = list.Where(s => s.channel == (int)ChannelType.粤语).ToList();
77 if (song != null && song.Count > 0)
78 {
79 var s = song[0];
80 YY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
81 YY.Title = ChannelType.粤语.ToString();
82 YY.Message = s.artist "-" s.title;
83 }
84 else
85 {
86 YY.Title = ChannelType.粤语.ToString();
87 YY.Message = "No Song!";
88 }
89
90 song = list.Where(s => s.channel == (int)ChannelType.最爱).ToList();
91 if (song != null&&song.Count>0)
92 {
93 var s = song[0];
94 FAV.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
95 FAV.Title = ChannelType.最爱.ToString();
96 FAV.Message = s.artist "-" s.title;
97 }
98 else
99 {
100 FAV.Title = ChannelType.最爱.ToString();
101 FAV.Message = "No Song!";
102 }
103
代码语言:javascript复制104 }
点击频道导航到MainPage:
代码语言:javascript复制 1 HubTile ht = sender as HubTile;
代码语言:javascript复制2 this.NavigationService.Navigate(new Uri("/MainPage.xaml?Channle=" ht.Title, UriKind.Relative));