/// <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 { string groupid = (string)e.NavigationParameter; SampleDataItem item; if (groupid.Contains("Group-0-") || groupid.Contains("Group-1-")) { item = await SampleDataSource.GetItemAsync1((string)e.NavigationParameter); } else { item = await SampleDataSource.GetItemAsync((string)e.NavigationParameter); } this.DefaultViewModel["Item"] = item; ContentRoot.Title = item.Title; details.Text = item.Description; rules.Text = item.Content; string contact = item.Contacts; while (true) { if (contact.IndexOf(':') == -1) { break; } name.Add(contact.Substring(0, contact.IndexOf(':'))); contact = contact.Substring(contact.IndexOf(':') + 1); phn.Add(contact.Substring(0, contact.IndexOf('\n'))); try { contact = contact.Substring(contact.IndexOf('\n') + 1); } catch (Exception) { break; } } for (int i = 0; i < name.Count; i++) { TextBlock contacts = new TextBlock(); contacts.Foreground = new SolidColorBrush(Colors.White); contacts.FontSize = 18.0; contacts.TextWrapping = TextWrapping.Wrap; contacts.Text = name[i] + ": " + phn[i]; StackPanel st = new StackPanel(); st.Orientation = Orientation.Horizontal; AppBarButton call = new AppBarButton(); SymbolIcon ic = new SymbolIcon(Symbol.Phone); call.Icon = ic; call.Tag = i; call.Click += new RoutedEventHandler(Action_Call); AppBarButton msg = new AppBarButton(); SymbolIcon ic1 = new SymbolIcon(Symbol.Message); msg.Icon = ic1; msg.Tag = i; msg.Click += new RoutedEventHandler(Action_Message); st.Children.Add(call); st.Children.Add(msg); ContactsList.Children.Add(contacts); ContactsList.Children.Add(st); } } catch (Exception eq) { } }