示例#1
0
        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));
        }
示例#2
0
        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));
        }