public WeatherListPage() { InitializeComponent(); ViewModel = new WeatherListViewModel(); BindingContext = ViewModel; WeatherList.SetBinding(ListView.ItemsSourceProperty, nameof(ViewModel.WeatherRequests)); WeatherList.SetBinding(ListView.RefreshCommandProperty, nameof(ViewModel.RefreshCommand)); WeatherList.SetBinding(ListView.IsRefreshingProperty, nameof(ViewModel.IsRefreshing), BindingMode.OneWay); AddFavoriteToolbarItem.SetBinding(ToolbarItem.CommandProperty, nameof(ViewModel.AddFavoriteCommand)); }
public WeatherListPage() { InitializeComponent(); WeatherRequestDataTemplateSelector = new WeatherRequestDataTemplateSelector(); ViewModel = new WeatherListViewModel(); BindingContext = ViewModel; WeatherList.SetBinding(ItemsView <Cell> .ItemsSourceProperty, nameof(ViewModel.WeatherRequests)); WeatherList.SetBinding(ListView.RefreshCommandProperty, nameof(ViewModel.RefreshCommand)); WeatherList.SetBinding(ListView.IsRefreshingProperty, nameof(ViewModel.IsRefreshing), BindingMode.OneWay); WeatherList.ItemTemplate = WeatherRequestDataTemplateSelector; AddFavoriteToolbarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.AddFavoriteCommand)); }