Пример #1
0
 static void OnShowingPropertyChanging(BindableObject bindable, bool oldValue, bool newValue)
 {
     Device.BeginInvokeOnMainThread(delegate {
         LoadingView mv         = (LoadingView)bindable;
         mv.indicator.IsRunning = newValue;
         mv.IsVisible           = newValue;
     });
 }
Пример #2
0
        protected IncrementalPage()
        {
            RowsBeforeTheEndToLoad = 10;
            LastSearch             = string.Empty;
            SearchCount            = 0;
            AllItems = new ObservableCollection <T>();

            SearchBar = new SearchBar {
                Placeholder = "Search for..."
            };
            SearchBar.TextChanged += (sender, args) => LoadSearch(SearchBar.Text);

            LoadingView = new LoadingView {
                IsVisible = false
            };
            LoadingView.SetBinding(LoadingView.IsShowingProperty,
                                   new Binding("IsBusy", source: this));

            ListView = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                VerticalOptions     = LayoutOptions.FillAndExpand,
                SeparatorVisibility = SeparatorVisibility.Default,
                HasUnevenRows       = true,
                ItemsSource         = AllItems
            };
            ListView.ItemAppearing += (sender, e) => {
                if (!IsLoading)
                {
                    var foundIndex = AllItems.IndexOf(e.Item as T);
                    if (foundIndex == AllItems.Count - RowsBeforeTheEndToLoad)
                    {
                        LoadNextPage();
                    }
                }
            };

            var layout = new RelativeLayout();

            layout.Children.Add(
                SearchBar,
                Constraint.Constant(0),
                Constraint.Constant(0),
                Constraint.RelativeToParent(p => p.Width),
                Constraint.Constant(50)
                );
            layout.Children.Add(
                ListView,
                Constraint.Constant(0),
                Constraint.Constant(50),
                Constraint.RelativeToParent(p => p.Width),
                Constraint.RelativeToParent(p => p.Height - 50)
                );
            layout.Children.Add(
                LoadingView,
                Constraint.RelativeToParent(p => p.Width - 100),
                Constraint.RelativeToParent(p => p.Height - 100),
                Constraint.Constant(90),
                Constraint.Constant(90)
                );
            Content = layout;
        }