-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Templated indicator view - improvements #25642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/Controls/tests/TestCases.HostApp/Issues/Issues25598.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue25598"> | ||
| <VerticalStackLayout | ||
| Padding="30,0" | ||
| Spacing="25"> | ||
| <Button | ||
| AutomationId="AddItemButton" | ||
| Margin="0,20,0,0" | ||
| Command="{Binding AddRandomItemCommand}" | ||
| Text="Add Random Item"/> | ||
|
|
||
| <Button | ||
| AutomationId="RemoveItemButton" | ||
| Command="{Binding RemoveCurrentItemCommand}" | ||
| CommandParameter="{Binding Source={x:Reference carouselView}, Path=Position}" | ||
| Text="Remove Current Item"/> | ||
| <Grid | ||
| x:Name="cvGrid" | ||
| Margin="5,0" | ||
| RowDefinitions="Auto,50,Auto" | ||
| BackgroundColor="Transparent" | ||
| HorizontalOptions="FillAndExpand"> | ||
| <Label | ||
| Grid.Row="0" | ||
| FontSize="24" | ||
| Text="CarouselView + IndicatorView using DataTemplate!"/> | ||
| <CarouselView | ||
| x:Name="carouselView" | ||
| Grid.Row="1" | ||
| HorizontalOptions="FillAndExpand" | ||
| IndicatorView="indicatorView" | ||
| IsScrollAnimated="True" | ||
| ItemsSource="{Binding Items}" | ||
| ItemsUpdatingScrollMode="KeepScrollOffset" | ||
| VerticalOptions="EndAndExpand" | ||
| VerticalScrollBarVisibility="Default"> | ||
| <CarouselView.ItemTemplate> | ||
| <DataTemplate> | ||
| <Label | ||
| FontSize="18" | ||
| HorizontalOptions="Center" | ||
| Text="{Binding .}" | ||
| VerticalOptions="CenterAndExpand"/> | ||
| </DataTemplate> | ||
| </CarouselView.ItemTemplate> | ||
| </CarouselView> | ||
|
|
||
| <IndicatorView | ||
| x:Name="indicatorView" | ||
| Grid.Row="2" | ||
| HorizontalOptions="Center" | ||
| IndicatorColor="White" | ||
| SelectedIndicatorColor="#2040a0"> | ||
| <IndicatorView.IndicatorTemplate> | ||
| <DataTemplate> | ||
| <Border | ||
| BackgroundColor="Transparent" | ||
| HeightRequest="20" | ||
| Stroke="Black" | ||
| WidthRequest="20"> | ||
| <Border.StrokeShape> | ||
| <RoundRectangle CornerRadius="5"/> | ||
| </Border.StrokeShape> | ||
| </Border> | ||
| </DataTemplate> | ||
| </IndicatorView.IndicatorTemplate> | ||
| </IndicatorView> | ||
| </Grid> | ||
| <Grid | ||
| x:Name="cvGrid2" | ||
| Margin="5,0" | ||
| RowDefinitions="Auto,50,Auto" | ||
| BackgroundColor="Transparent" | ||
| HorizontalOptions="FillAndExpand"> | ||
| <Label | ||
| Grid.Row="0" | ||
| FontSize="24" | ||
| Text="CarouselView + IndicatorView NOT USING DataTemplate!"/> | ||
| <CarouselView | ||
| x:Name="carouselView2" | ||
| Grid.Row="1" | ||
| HorizontalOptions="FillAndExpand" | ||
| IndicatorView="indicatorView2" | ||
| IsScrollAnimated="True" | ||
| ItemsSource="{Binding Items}" | ||
| ItemsUpdatingScrollMode="KeepScrollOffset" | ||
| VerticalOptions="EndAndExpand" | ||
| VerticalScrollBarVisibility="Default"> | ||
| <CarouselView.ItemTemplate> | ||
| <DataTemplate> | ||
| <Label | ||
| FontSize="18" | ||
| HorizontalOptions="Center" | ||
| Text="{Binding .}" | ||
| VerticalOptions="CenterAndExpand"/> | ||
| </DataTemplate> | ||
| </CarouselView.ItemTemplate> | ||
| </CarouselView> | ||
|
|
||
| <IndicatorView | ||
| x:Name="indicatorView2" | ||
| Grid.Row="2" | ||
| HorizontalOptions="Center" | ||
| IndicatorColor="Black" | ||
| IndicatorsShape="Square" | ||
| SelectedIndicatorColor="#2040a0"/> | ||
| </Grid> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
42 changes: 42 additions & 0 deletions
42
src/Controls/tests/TestCases.HostApp/Issues/Issues25598.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [Issue(IssueTracker.Github, 25598, "IndicatorView with Template won't show when ItemSource reaches 0 Elements", PlatformAffected.Android)] | ||
| public partial class Issue25598 : ContentPage | ||
| { | ||
| public Issue25598() | ||
| { | ||
| InitializeComponent(); | ||
| BindingContext = new Issue25598ViewModel(); | ||
| } | ||
| } | ||
|
|
||
| public class Issue25598ViewModel : ViewModel | ||
| { | ||
| int _lastItemIndex = 3; | ||
|
|
||
| private ObservableCollection<string> _items = new() { "Item1", "Item2", "Item3" }; | ||
|
|
||
| public ObservableCollection<string> Items | ||
| { | ||
| get => _items; | ||
| set | ||
| { | ||
| if (_items != value) | ||
| { | ||
| _items = value; | ||
| OnPropertyChanged(nameof(Items)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public Command AddRandomItemCommand => new(() => Items.Add($"Item{++_lastItemIndex}")); | ||
|
|
||
| public Command RemoveCurrentItemCommand => new Command<int>(index => | ||
| { | ||
| if (index >= 0 && index < Items.Count) | ||
| Items.RemoveAt(index); | ||
| }); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25598.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue25598 : _IssuesUITest | ||
| { | ||
| public Issue25598(TestDevice testDevice) : base(testDevice) { } | ||
|
|
||
| public override string Issue => "IndicatorView with Template won't show when ItemSource reaches 0 Elements"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.IndicatorView)] | ||
| public void IndicatorWithTemplateShouldBeVisible() | ||
| { | ||
| App.WaitForElement("RemoveItemButton"); | ||
|
|
||
| for (int i = 0; i < 3; i++) | ||
| App.Click("RemoveItemButton"); | ||
|
|
||
| for (int i = 0; i < 3; i++) | ||
| App.Click("AddItemButton"); | ||
|
|
||
| VerifyScreenshot(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| } | ||
| } | ||
Binary file added
BIN
+82.9 KB
...ests/TestCases.iOS.Tests/snapshots/ios/IndicatorWithTemplateShouldBeVisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test seems to crash on Windows:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's something wrong with the UI test with the Carousel view with the data template on Windows. Probably we will have the same crash without any changes. Like we do in this PR: #24776