Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ internal void SetCachedFirstItemSize(CoreGraphics.CGSize size)
[StructuredItemsView.FooterTemplateProperty.PropertyName] = MapFooterTemplate,
[StructuredItemsView.HeaderProperty.PropertyName] = MapHeaderTemplate,
[StructuredItemsView.FooterProperty.PropertyName] = MapFooterTemplate,
[StructuredItemsView.ItemsLayoutProperty.PropertyName] = MapItemsLayout,
[StructuredItemsView.ItemSizingStrategyProperty.PropertyName] = MapItemSizingStrategy,
[GroupableItemsView.GroupHeaderTemplateProperty.PropertyName] = MapHeaderTemplate,
[GroupableItemsView.GroupFooterTemplateProperty.PropertyName] = MapFooterTemplate,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28656.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?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.Issue28656">
<Grid RowDefinitions="Auto,*,*">
<Button
Command="{Binding ChangeLayoutCommand}"
AutomationId="ChangeLayoutButton"
Text="Change layout type"/>
<CollectionView Grid.Row="1"
ItemsSource="{Binding Items}">
<CollectionView.Triggers>
<DataTrigger
Binding="{Binding IsGridLayout}"
TargetType="CollectionView"
Value="False">
<Setter Property="ItemsLayout">
<Setter.Value>
<GridItemsLayout Orientation="Vertical"
Span="2"/>
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger
Binding="{Binding IsGridLayout}"
TargetType="CollectionView"
Value="True">
<Setter Property="ItemsLayout">
<Setter.Value>
<LinearItemsLayout Orientation="Vertical"/>
</Setter.Value>
</Setter>
</DataTrigger>
</CollectionView.Triggers>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Null}">
<Grid>
<Grid
BackgroundColor="Green"
HeightRequest="300"
Margin="10">
<Label
FontSize="26"
HorizontalOptions="Center"
Text="{Binding}"
TextColor="Blue"
VerticalOptions="Center"/>
</Grid>
</Grid>

</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView Grid.Row="2"
ItemsLayout="{Binding ItemsLayout}"
ItemsSource="{Binding Items}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Null}">
<Grid>
<Grid
BackgroundColor="Green"
HeightRequest="300"
Margin="10">
<Label
FontSize="26"
HorizontalOptions="Center"
Text="{Binding}"
TextColor="Blue"
VerticalOptions="Center"/>
</Grid>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</ContentPage>
51 changes: 51 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28656.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 28656, "CollectionView CollectionViewHandler2 does not change ItemsLayout on DataTrigger", PlatformAffected.iOS)]
public partial class Issue28656 : ContentPage
{
public Issue28656()
{
InitializeComponent();
BindingContext = new Issue28656ViewModel();
}

public partial class Issue28656ViewModel : ViewModel
{
private ItemsLayout _itemsLayout = new GridItemsLayout(2, ItemsLayoutOrientation.Vertical);
public ItemsLayout ItemsLayout
{
get => _itemsLayout;
set
{
_itemsLayout = value;
OnPropertyChanged();
}
}

private bool _isGridLayout = true;
public bool IsGridLayout
{
get => _isGridLayout;
set
{
_isGridLayout = value;
OnPropertyChanged();
}
}

public ObservableCollection<string> Items => [.. Enumerable.Range(0, 100).Select(i => $"Item {i}")];

public Command ChangeLayoutCommand { get; }

public Issue28656ViewModel()
{
ChangeLayoutCommand = new Command(() =>
{
IsGridLayout = !IsGridLayout;
ItemsLayout = IsGridLayout ? new GridItemsLayout(2, ItemsLayoutOrientation.Vertical) : new LinearItemsLayout(ItemsLayoutOrientation.Vertical);
});
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue28656 : _IssuesUITest
{
public Issue28656(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "CollectionView CollectionViewHandler2 does not change ItemsLayout on DataTrigger";

[Test]
[Category(UITestCategories.CollectionView)]
public void CollectionViewShouldChangeItemsLayout()
{
App.WaitForElement("ChangeLayoutButton");
App.Click("ChangeLayoutButton");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading