Skip to content

Commit 19b94b8

Browse files
SyedAbdulAzeemSF4852PureWeen
authored andcommitted
[Windows] Fix for IndicatorView using templated icons not working (#28905)
* [Windows] Fix for 7144 ( IndicatorView using templated icons not working ) * [Windows] Fix for 7144 ( IndicatorView using templated icons not working ) * [Windows] Fix for 7144 ( IndicatorView using templated icons not working ) * [Windows] Fix for 7144 ( IndicatorView using templated icons not working ) * [Windows] Fix for 7144 ( IndicatorView using templated icons not working ) * [Windows] Fix for 7144 ( IndicatorView using templated icons not working ) * [Windows] Fix for 7144 ( IndicatorView using templated icons not working ) SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 committed last week * Have added snapshots for iOS and Android * Have added the snapshots * [Windows] Fix for 7144 ( IndicatorView using templated icons not working )
1 parent f834bee commit 19b94b8

File tree

7 files changed

+113
-7
lines changed

7 files changed

+113
-7
lines changed
48.8 KB
Loading
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System.Collections.ObjectModel;
2+
3+
namespace Controls.TestCases.HostApp.Issues;
4+
5+
[Issue(IssueTracker.Github, 7144, "IndicatorView using templated icons not working", PlatformAffected.UWP)]
6+
public class Issue7144 : ContentPage
7+
{
8+
ObservableCollection<string> Items { get; set; } = new ObservableCollection<string>() { "Item1", "Item2" };
9+
10+
public Issue7144()
11+
{
12+
Grid grid = new Grid();
13+
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });
14+
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
15+
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
16+
17+
IndicatorView indicatorViewWithDataTemplate = new IndicatorView
18+
{
19+
Margin = new Thickness(0, 0, 0, 40),
20+
HorizontalOptions = LayoutOptions.Center,
21+
IndicatorColor = Colors.Black,
22+
SelectedIndicatorColor = Colors.Green
23+
};
24+
25+
indicatorViewWithDataTemplate.IndicatorTemplate = new DataTemplate(() =>
26+
{
27+
Image image = new Image()
28+
{
29+
Source = "dotnet_bot.png",
30+
HeightRequest = 15,
31+
WidthRequest = 15,
32+
};
33+
return image;
34+
});
35+
36+
CarouselView carouselView = new CarouselView
37+
{
38+
ItemsSource = Items,
39+
Loop = false,
40+
IndicatorView = indicatorViewWithDataTemplate,
41+
ItemTemplate = new DataTemplate(() =>
42+
{
43+
StackLayout stackLayout = new StackLayout();
44+
45+
Label label = new Label
46+
{
47+
FontAttributes = FontAttributes.Bold,
48+
FontSize = 24,
49+
HorizontalOptions = LayoutOptions.Center,
50+
VerticalOptions = LayoutOptions.Center
51+
};
52+
label.SetBinding(Label.TextProperty, ".");;
53+
54+
stackLayout.Children.Add(label);
55+
56+
return stackLayout;
57+
})
58+
};
59+
60+
Label label = new Label
61+
{
62+
AutomationId = "descriptionLabel",
63+
Text = "The test case fails if the IndicatorView DataTemplate is not displayed",
64+
FontAttributes = FontAttributes.Bold,
65+
FontSize = 24,
66+
HorizontalOptions = LayoutOptions.Center,
67+
VerticalOptions = LayoutOptions.Center
68+
};
69+
70+
grid.Add(carouselView, 0, 0);
71+
grid.Add(indicatorViewWithDataTemplate, 0, 1);
72+
grid.Add(label, 0, 2);
73+
74+
Content = grid;
75+
}
76+
}
77+
78+
24.6 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue7144 : _IssuesUITest
8+
{
9+
public Issue7144(TestDevice device) : base(device)
10+
{
11+
}
12+
13+
public override string Issue => "IndicatorView using templated icons not working";
14+
15+
[Test]
16+
[Category(UITestCategories.IndicatorView)]
17+
public void IndicatorViewWithTemplatedIcon()
18+
{
19+
App.WaitForElement("descriptionLabel");
20+
VerifyScreenshot();
21+
}
22+
}
11.7 KB
Loading
51.1 KB
Loading

src/Core/src/Platform/Windows/MauiPageControl.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class MauiPageControl : ItemsControl
2020
WBrush? _fillColor;
2121
ObservableCollection<WShape>? _dots;
2222

23+
internal bool UseShapeIndicator => _indicatorView == null || (_indicatorView is ITemplatedIndicatorView templatedView && templatedView.IndicatorsLayoutOverride != null);
24+
2325
public MauiPageControl()
2426
{
2527
HorizontalAlignment = Microsoft.UI.Xaml.HorizontalAlignment.Center;
@@ -35,15 +37,17 @@ public void SetIndicatorView(IIndicatorView indicatorView)
3537
}
3638

3739
internal void UpdateIndicatorsColor()
38-
{
39-
if (_indicatorView == null)
40+
{
41+
if (UseShapeIndicator)
42+
{
4043
return;
44+
}
4145

42-
if (_indicatorView.IndicatorColor is SolidPaint solidPaint)
46+
if (_indicatorView?.IndicatorColor is SolidPaint solidPaint)
4347
_fillColor = solidPaint?.ToPlatform();
44-
if (_indicatorView.SelectedIndicatorColor is SolidPaint selectedSolidPaint)
48+
if (_indicatorView?.SelectedIndicatorColor is SolidPaint selectedSolidPaint)
4549
_selectedColor = selectedSolidPaint.ToPlatform();
46-
var position = _indicatorView.Position;
50+
var position = _indicatorView?.Position;
4751
int i = 0;
4852
foreach (var item in Items)
4953
{
@@ -54,13 +58,15 @@ internal void UpdateIndicatorsColor()
5458

5559
internal void CreateIndicators()
5660
{
57-
if (_indicatorView == null)
61+
if (UseShapeIndicator)
62+
{
5863
return;
64+
}
5965

6066
var position = GetIndexFromPosition();
6167
var indicators = new List<WShape>();
6268

63-
var indicatorCount = _indicatorView.GetMaximumVisible();
69+
var indicatorCount = _indicatorView?.GetMaximumVisible();
6470
if (indicatorCount > 0)
6571
{
6672
for (int i = 0; i < indicatorCount; i++)

0 commit comments

Comments
 (0)