private void ScrollRefresh() { var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = MainScroll, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding <ScrollModel>(PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding <ScrollModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); TabGrid.Children.Add(refreshView, 0, 3); refreshView.RefreshCommand = new Command(() => { refreshView.IsRefreshing = false; LoadingInitAsync(); }); }
public ListViewPage(bool insideLayout) { Title = "ListView (Pull to Refresh)"; BindingContext = new TestViewModel(this); var listView = new ListView(); //ListView now has a built in pull to refresh! //You most likely could enable the listview pull to refresh and use it instead of the refresh view //listView.IsPullToRefreshEnabled = true; // //listView.SetBinding<TestViewModel>(ListView.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); //listView.SetBinding<TestViewModel>(ListView.RefreshCommandProperty, vm => vm.RefreshCommand); listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, new Binding("Items")); //ListView now has a built in pull to refresh! //You most likely could disable the listview pull to refresh and re-enable this //However, I wouldn't recommend that. var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, listView } }, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding(PullToRefreshLayout.IsRefreshingProperty, , new Binding("IsBusy", BindingMode.OneWay)); refreshView.SetBinding(PullToRefreshLayout.RefreshCommandProperty, new Binding("RefreshCommand")); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public ScrollViewPage(bool insideLayout) { var random = new Random(); Title = "ScrollView (Pull to Refresh)"; BindingContext = new TestViewModel(this); var grid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowSpacing = 0, ColumnSpacing = 0 }; var scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = grid }; for (int i = 0; i < 20; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); for (int j = 0; j < 20; j++) { if (i == 0) { grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } grid.Children.Add(new BoxView { HeightRequest = 50, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }, i, j); } } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = scrollView, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding(PullToRefreshLayout.IsRefreshingProperty, new Binding("IsBusy", BindingMode.OneWay)); refreshView.SetBinding(PullToRefreshLayout.RefreshCommandProperty, new Binding("RefreshCommand")); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public ListViewPage(bool insideLayout) { Title = "ListView (Pull to Refresh)"; BindingContext = new TestViewModel (this); var listView = new ListView (); //ListView now has a built in pull to refresh! //You most likely could enable the listview pull to refresh and use it instead of the refresh view //listView.IsPullToRefreshEnabled = true; // //listView.SetBinding<TestViewModel>(ListView.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); //listView.SetBinding<TestViewModel>(ListView.RefreshCommandProperty, vm => vm.RefreshCommand); listView.SetBinding<TestViewModel> (ItemsView<Cell>.ItemsSourceProperty, vm => vm.Items); //ListView now has a built in pull to refresh! //You most likely could disable the listview pull to refresh and re-enable this //However, I wouldn't recommend that. var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, listView } }, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding<TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy); refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public StackLayoutPage(bool insideLayout) { var random = new Random(); Title = "StackLayout (Pull to Refresh)"; BindingContext = new TestViewModel(this); var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0 }; for (int i = 0; i < 20; i++) { stack.Children.Add(new BoxView { HeightRequest = 150, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }); } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = stack, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding <TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding <TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { var activity = new ActivityIndicator(); activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); Content = new StackLayout { Spacing = 0, Children = { activity, new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public StackLayout CreateScrollableFeedView(List <PostItemStackLayout> PostsContent, string placeholder, string scopeName, string groupid = null) { StackLayout stack = new StackLayout(); if (PostsContent != null && PostsContent.Count > 0) { Debug.WriteLine("Posts found"); feedPosts = Util.CreateFeed(PostsContent); ScrollFeed = new ScrollView { Content = feedPosts }; refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = ScrollFeed, RefreshColor = Color.FromHex("#3498db"), IsPullToRefreshEnabled = true }; refreshView.SetBinding(PullToRefreshLayout.IsRefreshingProperty, new Xamarin.Forms.Binding() { Path = "IsBusy", Mode = BindingMode.OneWay }); refreshView.SetBinding(PullToRefreshLayout.RefreshCommandProperty, new Xamarin.Forms.Binding() { Path = "RefreshCommand" }); stack = new StackLayout { Orientation = StackOrientation.Vertical, Children = { refreshView } }; } else { Label NoPostsLabel = new Label { Text = "Be the first to start this secret file!", TextColor = Color.Silver, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill }; refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Content = NoPostsLabel, RefreshColor = Color.FromHex("#3498db"), IsPullToRefreshEnabled = true }; stack = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { refreshView } }; } return(UIBuilder.AddFloatingActionButtonToStackLayout(stack, "ic_add_white_24dp.png", new Command(async() => { Navigation.PushAsync(new CreatePostPage(refreshHandler, "Add a Secret to " + this.Title, groupname, groupid)); }), Color.FromHex(Values.PURPLE), Color.FromHex(Values.GOOGLEBLUE))); }
public ScrollViewPage(bool insideLayout) { var random = new Random(); Title = "ScrollView (Pull to Refresh)"; BindingContext = new TestViewModel (this); var grid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowSpacing = 0, ColumnSpacing = 0 }; var scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = grid }; for (int i = 0; i < 20; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition{ Width = GridLength.Auto }); for (int j = 0; j < 20; j++) { if (i == 0) { grid.RowDefinitions.Add(new RowDefinition{ Height = GridLength.Auto }); } grid.Children.Add(new BoxView { HeightRequest = 50, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }, i, j); } } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = scrollView, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding<TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public StackLayoutPage(bool insideLayout) { var random = new Random(); Title = "StackLayout (Pull to Refresh)"; BindingContext = new TestViewModel (this); var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0 }; for (int i = 0; i < 20; i++) { stack.Children.Add(new BoxView { HeightRequest = 150, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }); } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = stack, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding<TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { var activity = new ActivityIndicator(); activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); Content = new StackLayout { Spacing = 0, Children = { activity, new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }