public CarouselSampleSrollView() { _carouselView = new CardCarouselView { ItemTemplate = new DataTemplate(GetCardItem), Children = { new IndicatorsControl { SelectedIndicatorStyle = new Style(typeof(Frame)) { BasedOn = DefaultIndicatorItemStyles.DefaultSelectedIndicatorItemStyle, Setters = { new Setter { Property = BackgroundColorProperty, Value = Color.Red } } } } } }; _carouselView.SetBinding(CardsView.ItemsSourceProperty, nameof(CarouselSampleScrollViewModel.Items)); Title = "CarouselView scroll"; Content = _carouselView; BindingContext = new CarouselSampleScrollViewModel(); }
public CarouselSampleDoubleView() { var cardsView = new CardCarouselView { ItemTemplate = new DataTemplate(GetCardItem) }; cardsView.SetBinding(CardsView.ItemsSourceProperty, "Items"); cardsView.SetBinding(CardsView.SelectedIndexProperty, "CurrentIndex"); Title = "CarouselView Double Carousel"; Content = cardsView; BindingContext = new CarouselSampleDoubleViewModel(); }
private View GetCardItem() { var label = new Label { TextColor = Color.White, FontSize = 50, HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold }; label.SetBinding(Label.TextProperty, "Number"); AbsoluteLayout.SetLayoutFlags(label, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(label, new Rectangle(.5, 1, 1, .5)); var cardsView = new CardCarouselView { ItemTemplate = new DataTemplate(() => { var subCard = new ContentView(); subCard.SetBinding(BackgroundColorProperty, "Color"); return(subCard); }) }; cardsView.SetBinding(CardsView.ItemsSourceProperty, "Items"); cardsView.SetBinding(CardsView.SelectedIndexProperty, "CurrentIndex"); AbsoluteLayout.SetLayoutFlags(cardsView, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(cardsView, new Rectangle(.5, 0, 1, .5)); return(new AbsoluteLayout { BackgroundColor = Color.Black, Children = { cardsView, label } }); }
public CarouselSampleListView() { BindingContext = new CarouselSampleListViewModel(); var carousel = new CardCarouselView { ItemTemplate = new ListTemplateSelector() }; carousel.SetBinding(CardsView.ItemsSourceProperty, nameof(CarouselSampleListViewModel.Cards)); Content = carousel; }
public CarouselSampleListView() { BindingContext = new CarouselSampleListViewModel(); var carousel = new CardCarouselView { OppositePanDirectionDisablingThreshold = 1, ItemTemplate = new ListTemplateSelector() }; carousel.SetBinding(CardsView.ItemsSourceProperty, nameof(CarouselSampleListViewModel.Cards)); Content = carousel; }
public Onboarding() { Padding = new Thickness(0); _carouselView = new PanCardView.CarouselView { ItemTemplate = new DataTemplate(GetCardItem), Children = { new IndicatorsControl { SelectedIndicatorStyle = new Style(typeof(Frame)) { BasedOn = DefaultIndicatorItemStyles.DefaultSelectedIndicatorItemStyle, Setters = { new Setter { Property = BackgroundColorProperty, Value = Color.FromRgb(70, 120, 200) } } }, UnselectedIndicatorStyle = new Style(typeof(Frame)) { BasedOn = DefaultIndicatorItemStyles.DefaultUnselectedIndicatorItemStyle, Setters = { new Setter { Property = BackgroundColorProperty, Value = Color.FromRgb(70, 120, 200) }, new Setter { Property = OpacityProperty, Value = 0.5 } } } } } }; _carouselView.SetBinding(CardsView.ItemsSourceProperty, nameof(OnboardingItemsSource.AllItems)); Title = "Onboarding"; Content = OnboardingGrid(_carouselView); BindingContext = new OnboardingItemsSource(); }
public ImageViewer(FoodItem food) { NavigationPage.SetHasNavigationBar(this, false); int index = 0; CurrentIndex = index; bool indexSet = false; List <FoodItem> FoodItems = GlobalVariables.getFoodItems(); list = new Dictionary <int, byte[]>(); foreach (var i in FoodItems) { list.Add(i.ID, GlobalVariables.DeserializeStringToByteArray(i.IMGBYTES)); if (i == food && !indexSet) { index = list.Count - 1; indexSet = true; } } InitializeComponent(); PanCardView.CarouselView carouselView = new PanCardView.CarouselView { ItemTemplate = new DataTemplate(() => CardFactory.Creator.Invoke()), BackgroundColor = Color.Black }; carouselView.SetBinding(CardsView.CurrentContextProperty, nameof(ImageViewerModel.CurrentContext)); carouselView.SetBinding(CardsView.NextContextProperty, nameof(ImageViewerModel.NextContext)); carouselView.SetBinding(CardsView.PrevContextProperty, nameof(ImageViewerModel.PrevContext)); this.SetBinding(ImageViewer.CurrentIndexProperty, nameof(ImageViewerModel.CurrentIndex)); carouselView.SetBinding(CardsView.PanStartedCommandProperty, nameof(ImageViewerModel.PanStartedCommand)); carouselView.SetBinding(CardsView.PositionChangedCommandProperty, nameof(ImageViewerModel.PanPositionChangedCommand)); //ToolbarItem deleteOption = new ToolbarItem("Delete", "", new Action(() => { DeleteSelectedImage(); }), ToolbarItemOrder.Primary, 0); ToolbarItem editOption = new ToolbarItem("Edit", "", new Action(() => { Navigation.PushAsync(new EditDetailsPage(getCurrentID(), GlobalVariables.EntryType.UPDATE_ENTRY)); }), ToolbarItemOrder.Primary, 0); AbsoluteLayout UserPrefs = new AbsoluteLayout { Margin = 10 }; AbsoluteLayout.SetLayoutFlags(UserPrefs, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(UserPrefs, new Rectangle(1, 1, 1, 0.11)); StackLayout prefsView = new StackLayout(); AbsoluteLayout.SetLayoutFlags(prefsView, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(prefsView, new Rectangle(1, 1, 1, 1)); Grid grid = new Grid { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, RowDefinitions = { new RowDefinition { Height = new GridLength(25, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(25, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) } } }; Image healthIcon = new Image { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, WidthRequest = 25, HeightRequest = 25, Source = ImageSource.FromResource("SelfControl.Resources.health_icon.png") }; Image frequencyIcon = new Image { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, WidthRequest = 25, HeightRequest = 25, Source = ImageSource.FromResource("SelfControl.Resources.frequency_icon.png") }; healthRating = new Label { Text = "", FontSize = 15, VerticalTextAlignment = TextAlignment.Center, TextColor = Color.White }; frequencyRating = new Label { Text = "", FontSize = 15, VerticalTextAlignment = TextAlignment.Center, TextColor = Color.White }; grid.Children.Add(healthIcon, 0, 0); grid.Children.Add(healthRating, 1, 0); grid.Children.Add(frequencyIcon, 0, 1); grid.Children.Add(frequencyRating, 1, 1); prefsView.Children.Add(grid); UserPrefs.Children.Add(prefsView); carouselView.Children.Add(UserPrefs); Content = carouselView; ToolbarItems.Add(editOption); //ToolbarItems.Add(deleteOption); BindingContext = new ImageViewerModel(list, index); }