-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
212 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
80 changes: 80 additions & 0 deletions
80
src/Controls/tests/TestCases.HostApp/Issues/Issue21980.xaml
This file contains 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,80 @@ | ||
<?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.Issue21980"> | ||
<ContentPage.Resources> | ||
<Style x:Key="IndicatorViewTemplateStyle" TargetType="Image"> | ||
<Setter Property="VisualStateManager.VisualStateGroups"> | ||
<VisualStateGroupList> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"> | ||
<VisualState.Setters> | ||
<Setter Property="Source" Value="indicator_unselected" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Selected"> | ||
<VisualState.Setters> | ||
<Setter Property="Source" Value="indicator_selected" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateGroupList> | ||
</Setter> | ||
</Style> | ||
</ContentPage.Resources> | ||
<VerticalStackLayout> | ||
<Grid> | ||
<CarouselView | ||
ItemsSource="{Binding Images}" | ||
IndicatorView="IndicatorView" | ||
HorizontalScrollBarVisibility="Never" | ||
BackgroundColor="#ececec" | ||
WidthRequest="300" | ||
HeightRequest="450" | ||
Grid.Row="0"> | ||
<CarouselView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid> | ||
<Image | ||
Source="{Binding .}" | ||
WidthRequest="300" | ||
HeightRequest="450"/> | ||
</Grid> | ||
</DataTemplate> | ||
</CarouselView.ItemTemplate> | ||
</CarouselView> | ||
<Border | ||
HorizontalOptions="Center" | ||
VerticalOptions="End" | ||
Margin="16" | ||
Padding="3" | ||
BackgroundColor="White" | ||
StrokeShape="RoundRectangle 12" | ||
StrokeThickness="0" | ||
Grid.Row="0"> | ||
<IndicatorView | ||
x:Name="IndicatorView" | ||
IndicatorColor="Transparent" | ||
SelectedIndicatorColor="Transparent" | ||
Padding="0"> | ||
<IndicatorView.IndicatorTemplate> | ||
<DataTemplate> | ||
<Image | ||
HeightRequest="25" | ||
WidthRequest="25" | ||
Margin="0" | ||
Style="{StaticResource IndicatorViewTemplateStyle}" /> | ||
</DataTemplate> | ||
</IndicatorView.IndicatorTemplate> | ||
</IndicatorView> | ||
</Border> | ||
</Grid> | ||
<Button | ||
AutomationId="button" | ||
Text="Change Source" | ||
Command="{Binding ChangeSourceCommand}" | ||
HorizontalOptions="Center" | ||
WidthRequest="200" | ||
Margin="0,16"/> | ||
</VerticalStackLayout> | ||
</ContentPage> |
56 changes: 56 additions & 0 deletions
56
src/Controls/tests/TestCases.HostApp/Issues/Issue21980.xaml.cs
This file contains 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,56 @@ | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 21980, "IndicatorView with DataTemplate does not render correctly", PlatformAffected.All)] | ||
public partial class Issue21980 : ContentPage | ||
{ | ||
public Issue21980() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = new Issue21980ViewModel(); | ||
} | ||
} | ||
|
||
public class Issue21980ViewModel : INotifyPropertyChanged | ||
{ | ||
private readonly IReadOnlyList<string> _images1 = new List<string> | ||
{ | ||
"dotnet_bot.png", | ||
"dotnet_bot.png", | ||
}; | ||
|
||
private readonly IReadOnlyList<string> _images2 = new List<string>() | ||
{ | ||
"dotnet_bot.png", | ||
"dotnet_bot.png", | ||
"dotnet_bot.png", | ||
"dotnet_bot.png", | ||
}; | ||
|
||
private IReadOnlyList<string> _images = []; | ||
public IReadOnlyList<string> Images | ||
{ | ||
get => _images; | ||
set | ||
{ | ||
_images = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public Command ChangeSourceCommand { get; set; } | ||
|
||
public Issue21980ViewModel() | ||
{ | ||
Images = _images1; | ||
ChangeSourceCommand = new Command(() => Images = Images?.Count != _images1.Count ? _images1 : _images2); | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
void OnPropertyChanged([CallerMemberName] string propertyName = "") => | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} |
Binary file added
BIN
+417 Bytes
src/Controls/tests/TestCases.HostApp/Resources/Images/indicator_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+932 Bytes
src/Controls/tests/TestCases.HostApp/Resources/Images/indicator_unselected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21980.cs
This file contains 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,25 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue21980 : _IssuesUITest | ||
{ | ||
public override string Issue => "IndicatorView with DataTemplate does not render correctly"; | ||
|
||
public Issue21980(TestDevice testDevice) : base(testDevice) | ||
{ | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.IndicatorView)] | ||
public void IndicatorViewShouldRenderCorrectly() | ||
{ | ||
App.WaitForElement("button"); | ||
App.Click("button"); | ||
|
||
VerifyScreenshot(); | ||
} | ||
} | ||
} |