private static void ItemsSourceChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var hub = dependencyObject as ItemsHub; if (hub != null) { var items = e.NewValue as IEnumerable; if (items != null) { hub.Sections.Clear(); foreach (var item in items) { var section = new HubSection {DataContext = item, Header = item}; if (hub.ItemTemplateSelector != null) { section.ContentTemplate = hub.ItemTemplateSelector.SelectTemplate(item, dependencyObject); } else { section.ContentTemplate = hub.ItemTemplate; } section.HeaderTemplate = hub.ItemHeaderTemplate; hub.Sections.Add(section); } } } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { StorageFile jsonfile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/test.json")); string jsonString = await FileIO.ReadTextAsync(jsonfile); var Allhubs = JsonArray.Parse(jsonString); //Read json file, and deserialization the json string to Hubcontrol class. List <Hubcontrol> hubsources = new List <Hubcontrol>(); foreach (IJsonValue jsonValue in Allhubs) { if (jsonValue.ValueType == JsonValueType.Object) { JsonObject hubcontrolitem = jsonValue.GetObject(); hubsources.Add(new Hubcontrol() { Title = hubcontrolitem.GetNamedString("Title"), Length = hubcontrolitem.GetNamedString("Length"), Features = hubcontrolitem.GetNamedString("Features") }); } } //Create a new hub control, add hubsections which title is got from json Hub HubFromJson = new Hub(); foreach (Hubcontrol hubcontrolitem in hubsources) { HubSection sectionitem = new HubSection(); sectionitem.Header = hubcontrolitem.Title; HubFromJson.Sections.Add(sectionitem); } root.Children.Add(HubFromJson); }
private void OnSectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e) { HubSection section = e.Section; ViewModelBase viewModel = section.DataContext as ViewModelBase; viewModel.NavigateToSectionList(); }
private static void DataSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var data = e.NewValue as IEnumerable; var hub = d as Hub; var template = GetSectionTemplate(hub); var header = GetHeaderTemplate(hub); if (data == null || hub == null) { return; } hub.Sections.Clear(); foreach (var section in data) { var sect = new HubSection { DataContext = section, ContentTemplate = template, HeaderTemplate = header }; var hubData = section as IHubData; if (hubData != null) { sect.Header = hubData.Header; } hub.Sections.Add(sect); } }
/// <summary> /// Invoked when a HubSection header is clicked. /// </summary> /// <param name="sender">The Hub that contains the HubSection whose header was clicked.</param> /// <param name="e">Event data that describes how the click was initiated.</param> void Hub_SectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e) { HubSection section = e.Section; var platform = section.DataContext; this.Frame.Navigate(typeof(SectionPage), ((Platform)platform).Id); }
/// <summary> /// Invoked when a HubSection header is clicked. /// </summary> /// <param name="sender">The Hub that contains the HubSection whose header was clicked.</param> /// <param name="e">Event data that describes how the click was initiated.</param> void Hub_SectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e) { HubSection section = e.Section; //var group = section.DataContext; //this.Frame.Navigate(typeof(SectionPage), ((SampleDataGroup)group).UniqueId); //this.Frame.Navigate(typeof(SectionPage)); }
private static void ItemsSourceChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var hub = dependencyObject as ItemsHub; if (hub != null) { var items = e.NewValue as IEnumerable; if (items != null) { hub.Sections.Clear(); foreach (var item in items) { var section = new HubSection { DataContext = item, Header = item }; if (hub.ItemTemplateSelector != null) { section.ContentTemplate = hub.ItemTemplateSelector.SelectTemplate(item, dependencyObject); } else { section.ContentTemplate = hub.ItemTemplate; } section.HeaderTemplate = hub.ItemHeaderTemplate; hub.Sections.Add(section); } } } }
private void SectionOnDragStarting(UIElement sender, DragStartingEventArgs args) { lock (_sectionLock) { _sourceSection = sender as HubSection; } }
private static void ItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsHub hub = d as ItemsHub; if (hub != null) { IList items = e.NewValue as IList; if (items != null) { hub.Sections.Clear(); foreach (var item in items) { var section = new HubSection { DataContext = item, Header = item }; DataTemplate template = hub.ItemTemplate; section.ContentTemplate = template; hub.Sections.Add(section); } } } }
protected virtual HubSection GenerateHubSection(object item) { var section = new HubSection() { DataContext = item, Header = item, ContentTemplate = ItemTemplateSelector == null ? ItemTemplate : ItemTemplateSelector.SelectTemplate(item), }; if (!String.IsNullOrEmpty(IsHeaderInteractivePath)) { section.SetBinding(HubSection.IsHeaderInteractiveProperty, new Binding() { Path = new PropertyPath(this.IsHeaderInteractivePath) }); } if (!String.IsNullOrEmpty(HeaderPath)) { section.SetBinding(HubSection.HeaderProperty, new Binding() { Path = new PropertyPath(this.HeaderPath) }); } return(section); }
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { apiMealaroni menuItem = (apiMealaroni)e.NavigationParameter; BizName.Text = menuItem.selectedBiz.name+": "+menuItem.selectedItem.menu; HubSection overview = new HubSection(); overview.ContentTemplate = (DataTemplate)this.Resources["ItemTemplate"]; overview.Header = menuItem.selectedItem.name; overview.HeaderTemplate = (DataTemplate)this.Resources["HubSectionHeaderTemplate"]; itemHub.Sections.Add(overview); overview.DataContext = menuItem.selectedItem; if (menuItem.selectedItem.options != null) { foreach (IXmlNode option in menuItem.selectedItem.options.ChildNodes) { HubSection optionHub = new HubSection(); optionHub.HeaderTemplate = (DataTemplate)this.Resources["HubSectionHeaderTemplate"]; optionHub.ContentTemplate = (DataTemplate)this.Resources["OptionsTemplate"]; optionHub.Header = option.NodeName.Replace("_", " "); itemHub.Sections.Add(optionHub); IXmlNode encode = option.Attributes.GetNamedItem("enCode"); IXmlNode limitNode = option.Attributes.GetNamedItem("limit"); string limit = limitNode != null ? limitNode.NodeValue.ToString() : ""; string en = encode != null ? encode.NodeValue.ToString() : ""; optionHub.DataContext = menuItem.menuOptions.getOptions(option.NodeName, en, limit).ToList(); } } }
public void ScrollToSectionAnimated(Hub hub, HubSection section) { GeneralTransform transform = section.TransformToVisual(hub); Point point = transform.TransformPoint(new Point(0, 0)); ScrollViewer viewer = Hub.GetFirstDescendantOfType <ScrollViewer>(); viewer.ChangeView(point.X, null, null, false); }
/// <summary> /// 在单击 HubSection 标题时调用。 /// </summary> /// <param name="sender">包含单击了其标题的 HubSection 的中心。</param> /// <param name="e">描述如何启动单击的事件数据。</param> void Hub_SectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e) { HubSection section = e.Section; var group = section.DataContext; if (group is System.Collections.ObjectModel.ObservableCollection<NewsSample.Data.SampleDataGroup>) { return; } this.Frame.Navigate(typeof(SectionPage), ((SampleDataGroup)group).UniqueId); }
public HomePage() { InitializeComponent(); Bar = BottomAppBar; BottomAppBar = null; _spotlightSection = SpotlightSection; _spotlightIndex = MainHub.Sections.IndexOf(SpotlightSection); MainHub.Sections.Remove(_spotlightSection); Messenger.Default.Register <bool>(this, "spotlight", SpotlightLoaded); }
void Hub_SectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e) { HubSection section = e.Section; //var group = section.DataContext; //this.Frame.Navigate(typeof(SectionPage), ((SampleDataGroup)group).UniqueId); //↓【第6回】画面遷移先を修正する // var feed = section.DataContext as DataModel.Feed; this.Frame.Navigate(typeof(HistoryPage)); }
public HomePage() { InitializeComponent(); Bar = BottomAppBar; BottomAppBar = null; _spotlightSection = SpotlightSection; _spotlightIndex = MainHub.Sections.IndexOf(SpotlightSection); MainHub.Sections.Remove(_spotlightSection); Messenger.Default.Register<bool>(this, "spotlight", SpotlightLoaded); }
private void MoveToSection(HubSection section) { //허브를 재생목록으로 이동 var hub = Lime.Xaml.Helpers.ElementHelper.FindVisualParent <Hub>(section); var playlistSection = hub.Sections.FirstOrDefault(x => x.ViewModelName() == PlaylistViewModel.NAME); if (playlistSection != null) { hub.ScrollToSection(playlistSection); } }
void Hub_SectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e) { HubSection section = e.Section; var group = section.DataContext; //this.Frame.Navigate(typeof(SectionPage), ((SampleDataGroup)group).UniqueId); if (section.Name == "SearchSection") { ToggleSearchView(); } }
private async void Get_Centros() { ProgressRing LoadingSection = (ProgressRing)FindChildControl <ProgressRing>(Sections, "ProgressCentros"); HubSection Section2Header = (HubSection)FindChildControl <HubSection>(Sections, "Section2Header"); Section2Header.Visibility = Visibility.Collapsed; LoadingSection.Visibility = Visibility.Visible; var centros = await this.Find_Centros(); this.DefaultViewModel["Section2Items"] = centros; Section2Header.Visibility = Visibility.Visible; }
public static void LoggedInUI(Hub PanoramaControl, HubSection PanoramaLogin, HubSection PanoramaAccount) { if (PanoramaControl.Sections.Contains(PanoramaLogin)) { // AccountFunctions.logMsg("removing login screen"); PanoramaControl.Sections.Remove(PanoramaLogin); } if (!PanoramaControl.Sections.Contains(PanoramaAccount)) { // AccountFunctions.logMsg("adding account screen"); PanoramaControl.Sections.Insert(PanoramaControl.Sections.Count, PanoramaAccount); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); _vm.LoadData(); foreach (GalleryItemViewModel item in _vm.Items) { HubSection section = new HubSection(); section.Header = item.Title; section.ContentTemplate = (DataTemplate)Resources["SectionTemplate"]; section.DataContext = item; Hub.Sections.Add(section); } }
/// <summary> /// This method is called on toggling between the Zoomed In/Out views. /// It helps to zoom to the correct section of the hub control. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SemanticZoom_OnViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e) { //Only check for zoomed out view if (e.IsSourceZoomedInView == false) { //Get the index of the source item int index = ZoomedOutGrid.Items.IndexOf(e.SourceItem.Item); HubSection item = NormalHub.Sections[index]; //Make the scroll destination to point selected hub section e.DestinationItem.Item = item; } }
/// <summary> /// Handles the Loaded event of the HubSection control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void HubSection_Loaded(object sender, RoutedEventArgs e) { if (sender is HubSection) { this.hubReceipe = (HubSection)sender; if (nbCountReceipe > 1) { this.hubReceipe.Header = "Recettes"; } else { this.hubReceipe.Header = "Recette"; } } }
private void CreateHubSections() { foreach (var property in viewModel.Properties) { if (property.Type != PropertyBindingModel.Types.REGULAR) continue; HubSection hubSection = new HubSection(); hubSection.DataContext = property; hubSection.ContentTemplate = (DataTemplate)Application.Current.Resources["PropertyContentTemplate"]; hubSection.HeaderTemplate = (DataTemplate)Application.Current.Resources["PropertyHeaderTemplate"]; MainHub.Sections.Add(hubSection); } }
private void BuildHubControl() { HubControl.Sections.Clear(); var templateSelector = new ItemsShowcaseViewItemGroupDataTemplateSelector(); foreach (var itemGroup in ((ItemsShowcaseViewModel)DataContext).ItemGroups) { var hubSection = new HubSection(); var dataTemplate = new DataTemplate(); hubSection.Header = itemGroup.Key; hubSection.ContentTemplate = templateSelector.SelectTemplate(itemGroup, hubSection); hubSection.DataContext = itemGroup; HubControl.Sections.Add(hubSection); } }
/// <summary> /// Invoked when a HubSection header is clicked. /// </summary> /// <param name="sender">The Hub that contains the HubSection whose header was clicked.</param> /// <param name="e">Event data that describes how the click was initiated.</param> void Hub_SectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e) { HubSection section = e.Section; var viewModel = (MainViewModel)this.DataContext; var podcasts = viewModel.AllPodcasts.OrderBy(p => p.Podcast.Name).ToList(); var episodes = podcasts.SelectMany(p => p.Episodes).OrderByDescending(ep => ep.Episode.Published).ToList(); if (section.Header.Equals("Subscriptions")) { this.Frame.Navigate(typeof(PodcastsPage), podcasts); } if (section.Header.Equals("Episodes")) { this.Frame.Navigate(typeof(EpisodesPage), episodes); } }
public async static Task ScrollToSectionAnimated(this Hub hub, HubSection section) { // Find the internal scrollviewer and its current horizontal offset. var viewer = hub.GetFirstDescendantOfType<ScrollViewer>(); var current = viewer.HorizontalOffset; // Find the distance to scroll. var visual = section.TransformToVisual(hub); var point = visual.TransformPoint(new Point(0, 0)); var offset = point.X; // Scroll in a more or less animated way. var increment = offset / 24; for (int i = 1; i < 25; i++) { viewer.ChangeView((i * increment) + current, null, null, true); await Task.Delay(TimeSpan.FromMilliseconds(i)); } }
private static void DataSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var data = e.NewValue as IEnumerable; var hub = d as Hub; var template = GetSectionTemplate(hub); var header = GetHeaderTemplate(hub); if (data == null || hub == null) return; foreach (var section in data) { var sect = new HubSection { DataContext = section, ContentTemplate = template, HeaderTemplate = header }; var hubData = section as IHubData; if (hubData != null) { sect.Header = hubData.Header; } hub.Sections.Add(sect); } }
private void AddSection(object item, int index = -1) { var section = new HubSection { DataContext = item, Header = item, HeaderTemplate = this.SectionHeaderTemplate, ContentTemplate = this.SectionTemplate, }; if (index > -1) { this.Sections.Insert(index, section); } else { this.Sections.Add(section); } }
private static void ItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PowerHub hub = d as PowerHub; if (hub != null) { IList items = e.NewValue as IList; if (items != null) { hub.Sections.Clear(); for (int index = 0; index < items.Count; index++) { var item = items[index]; HubSection section = new HubSection(); if (index == 0) { // N1 only HACK !!! Very Lame! //section.Margin = new Thickness(95, section.Margin.Top, section.Margin.Right, // section.Margin.Bottom); section.Padding = new Thickness(115, 20, 20, 20); } section.DataContext = item; section.Header = item; DataTemplate template = hub.ItemTemplate; section.ContentTemplate = template; hub.Sections.Add(section); IViewItem viewItem = item as IViewItem; if (viewItem != null) { section.IsHeaderInteractive = viewItem.IsNavigable; section.SetBinding(HubSection.VisibilityProperty, new Binding() { Converter = new BooleanToVisibilityConverter(), Path = new PropertyPath("IsVisible"), Mode = BindingMode.OneWay }); } } } } }
private void RefreshTaskLists() { TaskHub.Sections.Clear(); foreach (var taskList in ViewModel.TaskListsViewModels) { var section = new HubSection() { DataContext = taskList, ContentTemplate = TaskListTemplate, Margin = new Thickness(0, 0, 0, 15), CanDrag = true, ManipulationMode = ManipulationModes.TranslateX }; section.DragStarting += SectionOnDragStarting; section.DragOver += SectionOnDragOver; section.DragEnter += SectionOnDragEnter; section.DragLeave += SectionOnDragLeave; TaskHub.Sections.Add(section); } }
private void FillFoodListHub(List <FoodList> foodLists, DateTime selectedDay) { var contentTemplate = this.Resources["FoodListTemplate"] as DataTemplate; int index = 0; for (int i = 0; i < foodLists.Count; i++) { var item = foodLists[i]; var section = new HubSection() { ContentTemplate = contentTemplate }; section.DataContext = item; this.FoodListHub.Sections.Add(section); if (item.Date.ToString("d.M.yyyy") == selectedDay.ToString("d.M.yyyy")) { index = i; } } this.FoodListHub.DefaultSectionIndex = index; }
private async void Page_Loaded(object sender, RoutedEventArgs e) { List <Device> devices = await IOTMessages.GetDevicesList(); foreach (Device device in devices) { IOTDevice dev = new IOTDevice(); if (device.Status.Equals(DeviceStatus.Enabled)) { dev.IsEnabled = true; } dev.LastExecutionTime = device.LastActivityTime; dev.ConnectionStateIOT = device.ConnectionState.ToString(); dev.IdIOT = device.Id; if (device.Id.Equals(App.deviceIDMobile)) { dev.IsDeviceHome = "Collapsed"; } else { dev.IsDeviceHome = "Visible"; } HubSection hubSection = new HubSection(); DataTemplate template = this.Resources["TemplateGrid"] as DataTemplate; TextBlock headerTextBlock = new TextBlock(); headerTextBlock.Text = device.Id; headerTextBlock.Foreground = new SolidColorBrush(Colors.LightSteelBlue); hubSection.Header = headerTextBlock; hubSection.Padding = new Thickness(40, 30, 150, 44); hubSection.DataContext = dev; hubSection.ContentTemplate = template; hSettings.Sections.Add(hubSection); } }
async private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { mealaroniApi = (apiMealaroni)e.NavigationParameter; BizName.Text = mealaroniApi.selectedBiz.name; await mealaroniApi.getMenu(mealaroniApi.selectedBiz.city, mealaroniApi.selectedBiz.state, mealaroniApi.selectedBiz.country, mealaroniApi.selectedBiz.phone); mealaroniApi.selectedBiz.storehours = mealaroniApi.menus[0].storehours; foreach(apiMealaroni.Menu menu in mealaroniApi.menus) { string menuName = menu.menu; HubSection menusection = new HubSection(); menusection.Header = menuName; menusection.Margin = MenuItemListView.Margin; menusection.ContentTemplate = (DataTemplate)this.Resources["MenuTemplate"]; menusection.HeaderTemplate = (DataTemplate)this.Resources["HubSectionHeaderTemplate"]; MenuHub.Sections.Add(menusection); menusection.DataContext = mealaroniApi.menuItems.Where(fd => fd.menu == menuName).ToList(); } MenuItemListView.Header = "Full Menu"; MenuItemListView.DataContext = mealaroniApi.menuItems; }
/// <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 static void ItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsHub hub = d as ItemsHub; if (hub != null) { IEnumerable items = e.NewValue as IEnumerable; if (items != null) { // hub.Sections.Clear(); var sec = hub.Sections.Where(h => (string)h.Tag == "dyn").ToList(); foreach (var hubSection in sec) { hub.Sections.Remove(hubSection); } foreach (var item in items) { HubSection section = new HubSection(); section.Tag = "dyn"; section.DataContext = item; section.HeaderTemplate = hub.ItemHeaderTemplate; Windows.UI.Xaml.DataTemplate template = hub.ItemTemplate; section.ContentTemplate = template; //hub.Sections.Add(section); hub.Sections.Insert(0, section); } } } }
public voting() { this.InitializeComponent(); //this.lb_counter // text = "<- Frage 1 von 22 ->" for (int i = 0; i < 10; i++) { // Liste mit einer Struktur erstellen, Struktur = id, HubSection HubSection hubSection = new HubSection(); TextBlock headerTextBlock = new TextBlock(); headerTextBlock.Text = "New Hub Section " + i; hubSection.Header = headerTextBlock; hubSection.Padding = new Thickness(40, 30, 150, 44); this.MainHub.Sections.Add(hubSection); } //Test //TextBlock NoArticlesTextBlock = (TextBlock)FindChildByName(this, "lbCounter"); //NoArticlesTextBlock.Text = "HALLO"; }
private void BuildHubControl() { HubControl.Sections.Clear(); var templateSelector = new ItemsShowcaseViewItemGroupDataTemplateSelector(); foreach(var itemGroup in ((ItemsShowcaseViewModel)DataContext).ItemGroups) { var hubSection = new HubSection(); var dataTemplate = new DataTemplate(); hubSection.Header = itemGroup.Key; hubSection.ContentTemplate = templateSelector.SelectTemplate(itemGroup, hubSection); hubSection.DataContext = itemGroup; HubControl.Sections.Add(hubSection); } }
private async void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (!IsNullOrWhiteSpace(args.QueryText) || args.QueryText.ToLower().Equals("o campo não pode ficar em branco!")) { QueryText = args.QueryText; if (!new RepositorioCanais().ObterTodos().Any(c => c.CollectionName.Equals(args.QueryText))) { StartWebRequest(new Uri(Format("https://itunes.apple.com/search?term={0}&media=podcast&artistTerm={0}&limit=1", args.QueryText))); while (TunesResult == null) { await Task.Delay(1); } if (TunesResult != null && AdicionarCanais(TunesResult)) { HubSection hubSection = new HubSection(); TextBlock headerTextBlock = new TextBlock(); headerTextBlock.Text = "New Hub Section"; hubSection.Header = headerTextBlock; hubSection.Padding = new Thickness(40, 30, 150, 44); object testDataTemplate; this.Resources.TryGetValue("testDataTemplate", out testDataTemplate); hubSection.ContentTemplate = testDataTemplate as DataTemplate; TestHub.Sections.Add(hubSection); var consultaepisodios = new RepositorioEpisodios().ObterTodos().Where(c => c.IdCanal == TunesResult.results[0].collectionId).ToList(); if (!consultaepisodios.Any()) { ObterLinksdePodcast(new Uri(new RepositorioCanais().ObterPeloId(TunesResult.results[0].collectionId).FeedUrl), TunesResult.results[0].collectionId); var binding = new ObservableCollection<string>(); var consulta = new RepositorioEpisodios().ObterTodos() .Where(c => c.IdCanal == TunesResult.results[0].collectionId) .Select(c => c.TitulodoEpisodio) .ToList(); foreach (var episodio in consulta) { binding.Add(episodio); } ListViewEpisodios.DataContext = binding; } else { var binding = new ObservableCollection<string>(); foreach (var episodio in consultaepisodios.Select(c => c.TitulodoEpisodio)) { binding.Add(episodio); } ListViewEpisodios.DataContext = binding; } } else { await new MessageDialog("Ocorreu um erro inesperado durante a execução, envie um e-mail para [email protected]", "Erro não esperado").ShowAsync(); } } else { var canal = new RepositorioCanais().ObterTodos().FirstOrDefault(c => c.CollectionName.Equals(QueryText)); var consultaepisodios = new RepositorioEpisodios().ObterTodos().Where(c => c.IdCanal == canal.IdCanal).ToList(); if (!consultaepisodios.Any()) { ObterLinksdePodcast(new Uri(canal.FeedUrl), canal.IdCanal); var binding = new ObservableCollection<string>(); var consulta = new RepositorioEpisodios().ObterTodos() .Where(c => c.IdCanal == canal.IdCanal) .Select(c => c.TitulodoEpisodio) .ToList(); foreach (var episodio in consulta) { binding.Add(episodio); } ListViewEpisodios.DataContext = binding; } else { var binding = new ObservableCollection<string>(); foreach (var episodio in consultaepisodios.Select(c => c.TitulodoEpisodio)) { binding.Add(episodio); } ListViewEpisodios.DataContext = binding; } } } else { sender.Text = "O campo não pode ficar em branco!"; } }
private static void ItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsHub hub = d as ItemsHub; if (hub != null) { IList items = e.NewValue as IList; if (items != null) { hub.Sections.Clear(); foreach (var item in items) { HubSection section = new HubSection(); section.DataContext = item; section.Header = item; section.ContentTemplate = hub.ItemTemplate; section.HeaderTemplate = hub.ItemHeaderTemplate; hub.Sections.Add(section); } if (hub.DefaultItem != null && hub.Sections.Any(p => p.DataContext == hub.DefaultItem)) hub.ScrollToSection(hub.Sections.FirstOrDefault(p => p.DataContext == hub.DefaultItem)); } } }