Nota
O acesso a esta página requer autorização. Podes tentar iniciar sessão ou mudar de diretório.
O acesso a esta página requer autorização. Podes tentar mudar de diretório.
As extensões ItemsView fornecem uma série de métodos de extensão que dão suporte à configuração de controles ItemsView, como CarouselView e CollectionView.
As extensões oferecem os seguintes métodos:
EmptyView
O método EmptyView define a propriedade EmptyView em um elemento ItemsView.
O seguinte exemplo define a EmptyView como um novo Label com o texto "The Collection is Empty":
new CollectionView().EmptyView(new Label().Text("The Collection is Empty"));
EmptyViewTemplate
O método EmptyViewTemplate define a propriedade EmptyViewTemplate em um elemento ItemsView.
O seguinte exemplo define o EmptyViewTemplate como um novo DataTemplate que contém um Label com o texto "The Collection is Empty":
new CollectionView().EmptyViewTemplate(new DataTemplate(() => new Label().Text("The Collection is Empty")));
ItemsSource
O método ItemsSource define a propriedade ItemsSource em um elemento ItemsView.
O seguinte exemplo define a ItemsSource como new string[] { "C#", "Markup", "Extensions" }
new CollectionView().ItemsSource(new string[] { "C#", "Markup", "Extensions" });
HorizontalScrollBarVisibility
O método HorizontalScrollBarVisibility define a propriedade HorizontalScrollBarVisibility em um elemento ItemsView.
O seguinte exemplo define a HorizontalScrollBarVisibility como ScrollBarVisibility.Never:
new CollectionView().HorizontalScrollBarVisibility(ScrollBarVisibility.Never);
VerticalScrollBarVisibility
O método VerticalScrollBarVisibility define a propriedade VerticalScrollBarVisibility em um elemento ItemsView.
O seguinte exemplo define a VerticalScrollBarVisibility como ScrollBarVisibility.Never
new CollectionView().VerticalScrollBarVisibility(ScrollBarVisibility.Never);
ScrollBarVisibility
O método ScrollBarVisibility define as propriedades VerticalScrollBarVisibility e HorizontalScrollBarVisibility em um elemento ItemsView.
O seguinte exemplo define a VerticalScrollBarVisibility e a HorizontalScrollBarVisibility como ScrollBarVisibility.Never:
new CollectionView().ScrollBarVisibility(ScrollBarVisibility.Never);
RemainingItemsThreshold
O método RemainingItemsThreshold define a propriedade RemainingItemsThreshold em um elemento ItemsView.
O seguinte exemplo define o RemainingItemsThreshold como 10:
new CollectionView().RemainingItemsThreshold(10);
RemainingItemsThresholdReachedCommand
O método RemainingItemsThresholdReachedCommand define a propriedade RemainingItemsThresholdReachedCommand em um elemento ItemsView.
O seguinte exemplo define o RemainingItemsThresholdReachedCommand como um novo Command:
new CollectionView().RemainingItemsThresholdReachedCommand(new Command(async () => await DisplayAlert("Threshold Reached", "", "OK")));
Há uma segunda sobrecarga que define as propriedades RemainingItemsThresholdReachedCommand e RemainingItemsThresholdReachedCommandParameter.
O seguinte exemplo define o RemainingItemsThresholdReachedCommand como um novo Command<string> e define o RemainingItemsThresholdReachedCommandParameter como "No Items Remaining":
new CollectionView().RemainingItemsThresholdReachedCommand(new Command<string>(async text => await DisplayAlert("Threshold Reached", text, "OK"), "No Items Remaining"));
RemainingItemsThresholdReachedCommandParameter
O método RemainingItemsThresholdReachedCommandParameter define a propriedade RemainingItemsThresholdReachedCommandParameter em um elemento ItemsView.
O seguinte exemplo define o RemainingItemsThresholdReachedCommandParameter como "Hello World":
new CollectionView().RemainingItemsThresholdReachedCommandParameter("Hello World");
ItemTemplate
O método ItemTemplate define a propriedade ItemTemplate em um elemento ItemsView.
O seguinte exemplo define o ItemTemplate como um novo DataTemplate que contém um Label cuja TextProperty está associada à ItemsSource:
new CollectionView().ItemTemplate(new DataTemplate(() => new Label().Bind(Label.TextProperty, Binding.SelfPath)));
ItemsUpdatingScrollMode
O método ItemsUpdatingScrollMode define a propriedade ItemsUpdatingScrollMode em um elemento ItemsView.
O seguinte exemplo define o ItemsUpdatingScrollMode como ItemsUpdatingScrollMode.KeepLastItemInView:
new CollectionView().ItemsUpdatingScrollMode(ItemsUpdatingScrollMode.KeepLastItemInView);
.NET MAUI Community Toolkit