/// <summary> /// Füllt die Seite mit Inhalt auf, der bei der Navigation übergeben wird. Gespeicherte Zustände werden ebenfalls /// bereitgestellt, wenn eine Seite aus einer vorherigen Sitzung neu erstellt wird. /// </summary> /// <param name="sender"> /// Die Quelle des Ereignisses, normalerweise <see cref="NavigationHelper"/> /// </param> /// <param name="e">Ereignisdaten, die die Navigationsparameter bereitstellen, die an /// <see cref="Frame.Navigate(Type, Object)"/> als diese Seite ursprünglich angefordert wurde und /// ein Wörterbuch des Zustands, der von dieser Seite während einer früheren /// beibehalten wurde. Der Zustand ist beim ersten Aufrufen einer Seite NULL.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Ein geeignetes Datenmodell für die problematische Domäne erstellen, um die Beispieldaten auszutauschen var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; }
/// <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; ObservableCollection<ZoomItem> zoomList = new ObservableCollection<ZoomItem>(); var hero = new List<HeroImageItem>(); hero.Add(new HeroImageItem() { HeroTitle = this.resourceLoader.GetString("HeroTitle") }); var about = new List<AboutItem>(); about.Add(new AboutItem() { AboutString = this.resourceLoader.GetString("ReadListTitle"), tag = "ReadList" }); about.Add(new AboutItem() { AboutString = this.resourceLoader.GetString("FavListTitle"), tag = "FavList" }); zoomList.Add(new ZoomItem() { Key = "", ItemContent = hero }); zoomList.Add(new ZoomItem() { Key = sampleDataGroups[0].Title, ItemContent = sampleDataGroups[0].Items }); zoomList.Add(new ZoomItem() { Key = sampleDataGroups[1].Title, ItemContent = sampleDataGroups[1].Items }); zoomList.Add(new ZoomItem() { Key = this.resourceLoader.GetString("HubSection3HeaderText"), ItemContent = sampleDataGroups }); zoomList.Add(new ZoomItem() { Key = this.resourceLoader.GetString("HubSection4HeaderText"), ItemContent = about }); this.itemcollectSource.Source = zoomList; //跳过封面图片的header outView.ItemsSource = itemcollectSource.View.CollectionGroups.Skip(1); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: 問題のドメインでサンプル データを置き換えるのに適したデータ モデルを作成します var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Items"] = sampleDataGroups; }
/// <summary> /// Popola la pagina con il contenuto passato durante la navigazione. Vengono inoltre forniti eventuali stati /// salvati durante la ricreazione di una pagina in una sessione precedente. /// </summary> /// <param name="sender"> /// Origine dell'evento. In genere <see cref="NavigationHelper"/> /// </param> /// <param name="e">Dati evento che forniscono il parametro di navigazione passato a /// <see cref="Frame.Navigate(Type, object)"/> quando la pagina è stata inizialmente richiesta e /// un dizionario di stato mantenuto da questa pagina nel corso di una sessione /// precedente. Lo stato è null la prima volta che viene visitata una pagina.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: creare un modello dati appropriato per il dominio problematico per sostituire i dati di esempio var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data try { var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; if (list.Count == 0) { for (int i = 0; i < 18; i++) { foreach (var item in sampleDataGroups.ElementAt(i).Items) { list.Add(item); } } } int gh = list.Count; var sampleDataGroups1 = await SampleDataSource.GetGroupsAsync1(); HubSection1.DataContext = sampleDataGroups1.ElementAt(0); HubSection2.DataContext = sampleDataGroups1.ElementAt(1); } catch (Exception eq) { } }
/// <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> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </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> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { isActiveProgressRing.IsActive = true; btnNext.IsEnabled = false; var finalgroups = new List <SampleDataGroup>(); var interestoptions = e.NavigationParameter as List <InterestOption>; // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); if (interestoptions != null) { var positiveinterests = interestoptions.Where(io => io.IsInterested).Select(io => io.GroupName).ToList(); sampleDataGroups = sampleDataGroups.Where(gr => positiveinterests.Contains(gr.Title)); } this.ItemsViewModel["Items"] = sampleDataGroups; itemsViewSource.Source = this.ItemsViewModel["Items"]; if (firstTimeInitialization) { //make a delay to load external images from web await Task.Delay(5000); isActiveProgressRing.IsActive = false; btnNext.IsEnabled = CanGoToNextPage(); firstTimeInitialization = false; } else { isActiveProgressRing.IsActive = false; btnNext.IsEnabled = CanGoToNextPage(); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; }
/// <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> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { Windows.Graphics.Display.DisplayInformation.AutoRotationPreferences = Windows.Graphics.Display.DisplayOrientations.None; var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); List <SampleDataGroup> groupsShown = new List <SampleDataGroup>(); groupsShown.Add(sampleDataGroups.First()); this.DefaultViewModel["Groups"] = groupsShown; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="Common.NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; // call this method each time the favourites page is loaded/navigated too readStuff(); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); DefaultViewModel["Groups"] = sampleDataGroups; // load our toggle switch states UserData.Provider = AppSettings.GetProviderO365() ? AuthProvider.MicrosoftOffice365 : AuthProvider.MicrosoftAccount; O365ToggleSwitch.IsOn = UserData.Provider == AuthProvider.MicrosoftOffice365; UserData.UseBeta = AppSettings.GetUseBeta(); UseBetaToggleSwitch.IsOn = UserData.UseBeta; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); var entrances = await client.GetEntrances(); var dayEntrances = await client.GetTodayEntrances(); this.DefaultViewModel["Groups"] = sampleDataGroups; // this.DefaultViewModel["DayEntrances"] = dayEntrances; this.DefaultViewModel["Entrances"] = entrances; System.Diagnostics.Debug.WriteLine(DateTime.Now.DayOfWeek.ToString().ToLower()); System.Diagnostics.Debug.WriteLine(dayEntrances.Count()); ((TimePicker)CommonHelper.FindChildControl <TimePicker>(this, "EntranceTimePicker")).Time = DateTime.Now.TimeOfDay; }
/// <summary> /// Popola la pagina con il contenuto passato durante la navigazione. Vengono inoltre forniti eventuali stati /// salvati durante la ricreazione di una pagina in una sessione precedente. /// </summary> /// <param name="sender"> /// Origine dell'evento. In genere <see cref="NavigationHelper"/> /// </param> /// <param name="e">Dati evento che forniscono il parametro di navigazione passato a /// <see cref="Frame.Navigate(Type, Object)"/> quando la pagina è stata inizialmente richiesta e /// un dizionario di stato mantenuto da questa pagina nel corso di una sessione /// precedente. Lo stato è null la prima volta che viene visitata una pagina.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: creare un modello dati appropriato per il DOMINIO problematico per sostituire i dati di esempio var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; checkMessages(); if (!Settings.Location) { Hub.DefaultSectionIndex = 1; } else { Hub.DefaultSectionIndex = 0; } checkVote(); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { // Featured recipe var favorites = await SampleDataSource.GetFavoriteRecipesAsync(1); this.DefaultViewModel["Section1Item"] = favorites.SingleOrDefault(); // International Cuisine var groups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Section2Items"] = groups; // Top rated var topRated = await SampleDataSource.GetTopRatedRecipesAsync(6); this.DefaultViewModel["Section3Items"] = topRated; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data //featured recipe var sampleDataItem = await SampleDataSource.GetItemAsync(GetRandomNumber(25));//gets a recipe data with random recipeId this.DefaultViewModel["Section1Item"] = sampleDataItem; //International Cusine var groups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Section2Items"] = groups; //var sampleDataGroup = await SampleDataSource.GetGroupAsync("Group-4"); //gets the top rated cusine on a random basis and displays the collection of its recipes var sampleDataGroup = await SampleDataSource.GetGroupAsync(GetRandomNumber(5)); this.DefaultViewModel["Section3Items"] = sampleDataGroup; }
private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { bool isDataDownloaded; try { var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; isDataDownloaded = true; } catch { isDataDownloaded = false; } if (!isDataDownloaded) { await new MessageDialog("Ошибка подключения").ShowAsync(); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="Common.NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { try { ConnectionProfile connection = NetworkInformation.GetInternetConnectionProfile(); bool internet = connection != null && connection.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess; var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); if (internet == true) { this.DefaultViewModel["Items"] = sampleDataGroups; } else { this.Frame.Navigate(typeof(Lost)); } } catch (Exception ex) { generateErrorHandler("Well, this is embarrassing", "We happened to encounter a minor error while we were working. Apologies!"); } }
public static async Task <SampleDataGroup> GetFavList() { ObservableCollection <SampleDataItem> list = new ObservableCollection <SampleDataItem>(); string favIdStr = LoadFavId(); var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); foreach (var group in sampleDataGroups) { foreach (var item in group.Items) { if (favIdStr.IndexOf(item.UniqueId) >= 0) { list.Add(item); } } } var resourceLoader = ResourceLoader.GetForCurrentView("Resources"); SampleDataGroup groupData = new SampleDataGroup("FavListId", resourceLoader.GetString("FavListTitle"), resourceLoader.GetString("FavListSubtitle"), "ms-appx:///Assets/DarkGray.png", "FavListDesc"); groupData.Items = list; return(groupData); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var groups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = groups; if (IsPhone) { // Hide the Hamburger buttons when it is on a phone. Use the app bar on the bottom of the screen. SplitView splitView = (SplitView)FindName("mainSplitView"); splitView.CompactPaneLength = 0; // Limit the width of the group list so the item list is partially visible for selection HubSection hybSection = (HubSection)FindName("groupList_HubSection"); hybSection.Width = 250; } else { // Hide the app bar when it is not on a phone. Use the Hamburger buttons on the left of the screen. CommandBar commandBar = (CommandBar)FindName("commandBar"); commandBar.Visibility = Visibility.Collapsed; } }
private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var queryText = e.NavigationParameter as String; // Initialize the results list. AllResultsCollection = new Dictionary <string, IEnumerable <SampleDataItem> >(); // Keep track of the number of matching items. var totalMatchingItems = 0; var filterList = new List <Filter>(); var groups = await SampleDataSource.GetGroupsAsync(); foreach (var group in groups) { var matchingItems = group.Items.Where( item => item.Title.IndexOf( queryText, StringComparison.CurrentCultureIgnoreCase) > -1); int numberOfMatchingItems = matchingItems.Count(); totalMatchingItems += numberOfMatchingItems; if (numberOfMatchingItems > 0) { AllResultsCollection.Add(group.Title, matchingItems); filterList.Add(new Filter(group.Title, numberOfMatchingItems)); } } filterList.Insert(0, new Filter("All", totalMatchingItems, true)); this.DefaultViewModel["QueryText"] = '\"' + queryText + '\"'; this.DefaultViewModel["Filters"] = filterList; this.DefaultViewModel["ShowFilters"] = true; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var queryText = e.NavigationParameter as String; // TODO: Application-specific searching logic. The search process is responsible for // creating a list of user-selectable result categories: // // filterList.Add(new Filter("<filter name>", <result count>)); // // Only the first filter, typically "All", should pass true as a third argument in // order to start in an active state. Results for the active filter are provided // in Filter_SelectionChanged below. var filterList = new List <Filter>(); var totalMatchingItems = 0; Results = new Dictionary <string, IEnumerable <SampleDataItem> >(); var groups = await SampleDataSource.GetGroupsAsync(); foreach (var group in groups) { var matchingItems = group.Items.Where(item => item.Title.ToLower().Contains(queryText.ToLower())); int numberOfMatchingItems = matchingItems.Count(); if (numberOfMatchingItems > 0) { Results.Add(group.Title, matchingItems); filterList.Add(new Filter(group.Title, numberOfMatchingItems)); } totalMatchingItems += numberOfMatchingItems; } filterList.Insert(0, new Filter("All", totalMatchingItems, true)); // Communicate results through the view model this.DefaultViewModel["QueryText"] = '\u201c' + queryText + '\u201d'; this.DefaultViewModel["Filters"] = filterList; this.DefaultViewModel["ShowFilters"] = filterList.Count > 1; }
/// <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) { // Featured recipe // var favorites = await SampleDataSource.GetFavoriteRecipesAsync(1); // this.DefaultViewModel["Section1Item"] = favorites.SingleOrDefault(); // International Cuisine var groups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Section2Items"] = groups; // Top rated var topRated = await SampleDataSource.GetTopRatedRecipesAsync(10); this.DefaultViewModel["Section3Items"] = topRated; this.DefaultViewModel["ZoomedOutList"] = this.GetSectionList(); if (HubPage.soundStream == null) { string fileLocation = "ms-appx:///Sound/Jay/"; string filename = "Jay_10.mp3"; //音乐文件sound.wav同样在sound文件夹中 var fs = RandomAccessStreamReference.CreateFromUri(new Uri(fileLocation + filename)); HubPage.soundStream = await fs.OpenReadAsync(); HubPage.myMediaElement.SetSource(HubPage.soundStream, ""); //这里已经开始播放了 } //var Citys = await SampleDataSource.GetCitysAsync(); ////获取本机ip //string reslocalIpInfo = httpPost("http://61.4.185.48:81/g/", "", "get", "gb2312"); //string[] reslocalIp = reslocalIpInfo.Split(new String[] { "var ip=\"", "\";var id=" }, StringSplitOptions.RemoveEmptyEntries); ////根据本机ip获取城市名 //string resCityNameInfo = httpPost("http://www.ip138.com/ips138.asp?ip=" + reslocalIp[0] + "&action=2", "", "get", "gb2312"); //string[] resCityName = resCityNameInfo.Split(new String[] { "本站主数据:", "</li><li>参考数据" }, StringSplitOptions.RemoveEmptyEntries); //string[] resCityNameN = resCityName[1].Split(new String[] { "省", "市" }, StringSplitOptions.RemoveEmptyEntries); ////根据城市名获取城市天气id //string cityId = ""; //foreach (cityInfo a in Citys) //{ // if (a.CityName == resCityNameN[1]) // { // cityId = a.CityID; // break; // } //} //string localIpInfo = httpPost("http://61.4.185.48:81/g/", "", "get", "gb2312"); //string[] cityId = localIpInfo.Split(new String[] { "var id=", ";if" }, StringSplitOptions.RemoveEmptyEntries); ////根据城市天气id获取天气详情 //string resWeatherInfo = httpPost("http://m.weather.com.cn/ks/" + cityId[1] + ".html", "", "get", "utf-8"); ////string resWeatherInfo = httpPost("http://www.weather.com.cn/atad/" + cityId + ".html", "", "get", "utf-8"); //JsonObject jsonObject = JsonObject.Parse(resWeatherInfo); //JsonObject jsonObjectR = jsonObject["sk_info"].GetObject(); //string temp = jsonObjectR["temp"].GetString(); //string resH = jsonObjectR["temp1"].GetString(); // this.DefaultViewModel["weatherInfo"] = jsonObjectR; }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; var tileId = e.TileId.ToString(); // Do not repeat app initialization when the Window already has content, // just ensure that the window is active. if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page. rootFrame = new Frame(); // Associate the frame with a SuspensionManager key. SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); await GetSettings(); await StatusBar.GetForCurrentView().HideAsync(); await SampleDataSource.GetGroupsAsync(); if (AppAccentColor != resourceLoader.GetString("Indigo")) { if (AppAccentColor == resourceLoader.GetString("Light Blue")) { Resources["AppMainColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 2, 136, 209)); Resources["CheckBoxBGColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 2, 150, 229)); } else if (AppAccentColor == resourceLoader.GetString("Teal")) { Resources["AppMainColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 121, 107)); Resources["CheckBoxBGColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 140, 124)); } else { Resources["AppMainColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 198, 40, 40)); Resources["CheckBoxBGColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 224, 45, 45)); } } if (AppBGColor == resourceLoader.GetString("Light")) { rootFrame.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 245, 245, 245)); } else { rootFrame.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 20, 20, 20)); Resources["AppBackgroundColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 20, 20, 20)); Resources["CommandBarBackgroundColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 25, 25, 25)); Resources["ItemForegroundColor"] = new SolidColorBrush(Colors.White); Resources["TextBlockColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 30, 30, 30)); Resources["TextBoxBorderBrush"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 10, 10, 10)); Resources["TextBlockForegroundColor"] = new SolidColorBrush(Colors.White); Resources["ItemPageTextBoxColor"] = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 30, 30, 30)); } rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { try { await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { // Something went wrong restoring state. // Assume there is no state and continue. } } // Place the frame in the current Window. Window.Current.Content = rootFrame; } else { if (tileId.Contains("id")) { if (!rootFrame.Navigate(typeof(SectionPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } rootFrame.BackStack.Clear(); } else if (tileId.Contains("App")) { if (!rootFrame.Navigate(typeof(HubPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } rootFrame.BackStack.Clear(); } } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter. if (tileId.Contains("id")) { if (!rootFrame.Navigate(typeof(SectionPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } else { if (!rootFrame.Navigate(typeof(HubPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } } // Ensure the current window is active. Window.Current.Activate(); }
private async void SetGroups() { Groups = await SampleDataSource.GetGroupsAsync(); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); DefaultViewModel["Groups"] = sampleDataGroups; }
async void MainPage_Loaded(object sender, RoutedEventArgs e) { var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); sampleArtists.DataContext = sampleDataGroups; }