-
Notifications
You must be signed in to change notification settings - Fork 0
/
HubPage.xaml.cs
175 lines (158 loc) · 6.46 KB
/
HubPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using Hub.Common;
using Hub.Data;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.Resources;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics.Display;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
// “中心应用程序”模板在 http://go.microsoft.com/fwlink/?LinkId=391641 上有介绍
namespace Hub
{
/// <summary>
/// 显示分组的项集合的页。
/// </summary>
public sealed partial class HubPage : Page
{
private readonly NavigationHelper navigationHelper;
private readonly ObservableDictionary defaultViewModel = new ObservableDictionary();
private readonly ResourceLoader resourceLoader = ResourceLoader.GetForCurrentView("Resources");
public HubPage()
{
this.InitializeComponent();
StatusBar.GetForCurrentView().HideAsync();
// 仅支持方向为纵向的中心
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
this.NavigationCacheMode = NavigationCacheMode.Required;
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
}
/// <summary>
/// 获取与此 <see cref="Page"/> 关联的 <see cref="NavigationHelper"/>。
/// </summary>
public NavigationHelper NavigationHelper
{
get { return this.navigationHelper; }
}
/// <summary>
/// 获取此 <see cref="Page"/> 的视图模型。
/// 可将其更改为强类型视图模型。
/// </summary>
public ObservableDictionary DefaultViewModel
{
get { return this.defaultViewModel; }
}
/// <summary>
/// 使用在导航过程中传递的内容填充页。 在从以前的会话
/// 重新创建页时,也会提供任何已保存状态。
/// </summary>
/// <param name="sender">
/// 事件的来源; 通常为 <see cref="NavigationHelper"/>
/// </param>
/// <param name="e">事件数据,其中既提供在最初请求此页时传递给
/// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供
/// 此页在以前会话期间保留的状态的
/// 字典。 首次访问页面时,该状态将为 null。</param>
private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
// TODO: 创建适用于问题域的合适数据模型以替换示例数据
var sampleDataGroups = await SampleDataSource.GetGroupsAsync();
this.DefaultViewModel["Groups"] = sampleDataGroups;
}
/// <summary>
/// 保留与此页关联的状态,以防挂起应用程序或
/// 从导航缓存中放弃此页。值必须符合
/// <see cref="SuspensionManager.SessionState"/> 的序列化要求。
/// </summary>
/// <param name="sender">事件的来源;通常为 <see cref="NavigationHelper"/></param>
///<param name="e">提供要使用可序列化状态填充的空字典
///的事件数据。</param>
private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
{
// TODO: 在此处保存页面的唯一状态。
}
/// <summary>
/// 显示在 <see cref="SectionPage"/> 中单击的组的详细信息。
/// </summary>
private void GroupSection_ItemClick(object sender, ItemClickEventArgs e)
{
var groupId = ((SampleDataGroup)e.ClickedItem).UniqueId;
if (!Frame.Navigate(typeof(SectionPage), groupId))
{
throw new Exception(this.resourceLoader.GetString("NavigationFailedExceptionMessage"));
}
}
/// <summary>
/// 显示在 <see cref="ItemPage"/> 中单击的项的详细信息。
/// </summary>
private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
{
// 导航至相应的目标页,并
// 通过将所需信息作为导航参数传入来配置新页
var itemId = ((SampleDataItem)e.ClickedItem).UniqueId;
if (!Frame.Navigate(typeof(ItemPage), itemId))
{
throw new Exception(this.resourceLoader.GetString("NavigationFailedExceptionMessage"));
}
}
#region NavigationHelper 注册
/// <summary>
/// 此部分中提供的方法只是用于使
/// NavigationHelper 可响应页面的导航方法。
/// <para>
/// 应将页面特有的逻辑放入
/// <see cref="NavigationHelper.LoadState"/>
/// 和 <see cref="NavigationHelper.SaveState"/> 的事件处理程序中。
/// 除了在早期会话期间保留的页面状态之外,
/// LoadState 方法中还提供导航参数。
/// </para>
/// </summary>
/// <param name="e">描述如何访问此页的事件数据。</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedFrom(e);
}
#endregion
private bool expand=false;
private void Hub_SectionsInViewChanged(object sender, SectionsInViewChangedEventArgs e)
{
if (e.AddedSections.Count > 0)
{
if (e.AddedSections[0].Header.ToString() == "个人中心")
{
Storyboard1.Begin();
expand = true;
}
else
{
if (expand=true)
{
Storyboard2.Begin();
expand = false;
}
}
}
}
private void startExpand()
{
}
}
}