Skip to content

Commit

Permalink
Merge pull request #1307 from unoplatform/dev/nich/listview-head-loop
Browse files Browse the repository at this point in the history
Fix to infinite loop with listviewHeaders
  • Loading branch information
NicolasChampagne authored Aug 2, 2019
2 parents 30a8be8 + fe077cf commit dbda38f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,20 @@ public void ListView_ListViewVariableItemHeightLong_InitializesTest()
// Assert initial state
Assert.IsNotNull(theListView.GetDependencyPropertyValue("DataContext"));
}

// HorizontalListViewGrouped isn't present on WASM
[Test]
[AutoRetry]
[ActivePlatforms(Platform.iOS, Platform.Android)]
public void ListView_ListViewWithHeader_InitializesTest()
{
Run("SamplesApp.Windows_UI_Xaml_Controls.ListView.HorizontalListViewGrouped");

_app.WaitForElement(_app.Marked("TargetListView"));
var theListView = _app.Marked("TargetListView");

// Assert initial state
Assert.IsNotNull(theListView.GetDependencyPropertyValue("DataContext"));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
<UserControl
x:Class="SamplesApp.Windows_UI_Xaml_Controls.ListView.HorizontalListViewGrouped"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:xamarin="http://uno.ui/xamarin"
mc:Ignorable="d ios android xamarin"
d:DesignHeight="2000"
d:DesignWidth="400">
<UserControl x:Class="SamplesApp.Windows_UI_Xaml_Controls.ListView.HorizontalListViewGrouped"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:xamarin="http://uno.ui/xamarin"
mc:Ignorable="d ios android xamarin"
d:DesignHeight="2000"
d:DesignWidth="400">
<UserControl.Resources>

<Style TargetType="ListViewHeaderItem"
x:Key="GroupHeaderContainerStyle">
x:Key="GroupHeaderContainerStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="Orange"
BorderThickness="10">
BorderThickness="10">
<ContentPresenter xamarin:Content="{TemplateBinding Content}"
xamarin:ContentTemplate="{TemplateBinding ContentTemplate}"
xamarin:ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
xamarin:ContentTemplate="{TemplateBinding ContentTemplate}"
xamarin:ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
</Border>
</ControlTemplate>
</Setter.Value>
Expand All @@ -38,46 +37,48 @@
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="SelectedIndex: "/>
<TextBlock Text="{Binding ElementName=TargetListView, Path=SelectedIndex}"/>
<TextBlock Text="SelectedIndex: " />
<TextBlock Text="{Binding ElementName=TargetListView, Path=SelectedIndex}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="SelectedItem: "/>
<TextBlock Text="{Binding ElementName=TargetListView, Path=SelectedItem}"/>
<TextBlock Text="SelectedItem: " />
<TextBlock Text="{Binding ElementName=TargetListView, Path=SelectedItem}" />
</StackPanel>
<Border Background="Red">
<ListView x:Name="TargetListView"
Height="300"
ItemsSource="{Binding [GroupedSampleItemsAsSource]}"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Auto"
Header="Header"
Footer="Footer">
Height="300"
ItemsSource="{Binding [GroupedSampleItemsAsSource]}"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Auto"
Header="Header"
Footer="Footer">
<ListView.HeaderTemplate>
<DataTemplate>
<Border Background="Green"
HorizontalAlignment="Stretch">
HorizontalAlignment="Stretch">
<TextBlock Text="{Binding}"
Margin="20" />
Margin="20" />
</Border>
</DataTemplate>
</ListView.HeaderTemplate>
<ListView.FooterTemplate>
<DataTemplate>
<Border Background="Purple">
<TextBlock Text="{Binding}"
Margin="20" />
Margin="20" />
</Border>
</DataTemplate>
</ListView.FooterTemplate>
<ListView.GroupStyle>
<GroupStyle HidesIfEmpty="True"
HeaderContainerStyle="{StaticResource GroupHeaderContainerStyle}"
>
<GroupStyle HidesIfEmpty="True"
HeaderContainerStyle="{StaticResource GroupHeaderContainerStyle}">
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Border Background="Blue">
<TextBlock Text="{Binding Key}" Foreground="Red" FontSize="32" Height="40"/>
<TextBlock Text="{Binding Key}"
Foreground="Red"
FontSize="32"
Height="40" />
</Border>
</DataTemplate>
</GroupStyle.HeaderTemplate>
Expand All @@ -86,14 +87,16 @@
<ListView.ItemTemplate>
<DataTemplate>
<Border Background="White">
<TextBlock Text="{Binding}" Foreground="Blue" Height="16"/>
<TextBlock Text="{Binding}"
Foreground="Blue"
Height="16" />
</Border>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal"
GroupHeaderPlacement="Top"/>
GroupHeaderPlacement="Top" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ private protected override void UpdateLayoutAttributesForItem(UICollectionViewLa
{
UpdateLayoutAttributesForGroupHeader(elementToAdjust, extentDifference, true);
}

updatingItem = null;
}
}
}
Expand Down

0 comments on commit dbda38f

Please sign in to comment.