private async void OnToolbarItemClicked(object sender, EventArgs e) { NewsInfo info; NewsToolbarItem tItem = (NewsToolbarItem)sender; if (tItem.Description == "rgn") { info = rgn.SelectedInfo; RegionProc(true); } else { info = new NewsInfo { Address = tItem.Address, Description = tItem.Description }; RegionProc(false); } if (toolBarItemSelected == info) { return; } toolBarItemSelected = info; if (!await viewModel.LoadAsync(info)) { Exit(); return; } Application.Current.Properties["Inf"] = NewsInfo.Serialize(info); await Application.Current.SavePropertiesAsync(); listView.ScrollTo(((RSSItem[])listView.ItemsSource).First(), ScrollToPosition.End, true); }
public App() { InitializeComponent(); if (!Properties.ContainsKey("Inf")) { Properties.Add("Inf", NewsInfo.Serialize(new NewsInfo { Address = "https://news.yandex.ru/index.rss", Description = "Главное" })); } if (!Properties.ContainsKey("Rgn")) { Properties.Add("Rgn", NewsInfo.Serialize(new NewsInfo { Address = "https://news.yandex.ru/Barnaul/index.rss", Description = "Алтайский край" })); } MainPage = new NavigationPage(new MainPage()); }
private async void RgnItemTaped(object sender, ItemTappedEventArgs e) { ListView list = (ListView)sender; SelectedInfo = (NewsInfo)list.SelectedItem; list.SelectedItem = null; ((MainPage)((NavigationPage)Application.Current.MainPage).RootPage).viewModel.LoadAsync(SelectedInfo); Application.Current.Properties["Inf"] = Application.Current.Properties["Rgn"] = NewsInfo.Serialize(SelectedInfo); await Application.Current.SavePropertiesAsync(); await Navigation.PopModalAsync(); }