Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara authored Nov 13, 2023
1 parent 6031682 commit d724375
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ private void Generate(
{
// Does not fit, wrap to the previous row
var availableSizeMinor = OM.Minor(availableSize);
OM.SetMinorStart(ref currentBounds, !double.IsInfinity(availableSizeMinor) ? availableSizeMinor - OM.Minor(desiredSize) : 0.0);
// If the last available size is finite, start from end and subtract our desired size.
// Otherwise, look at the last extent and use that for positioning.
OM.SetMinorStart(ref currentBounds, !double.IsInfinity(availableSizeMinor) ? availableSizeMinor - OM.Minor(desiredSize) : OM.MinorSize(LastExtent) - OM.Minor(desiredSize));
OM.SetMajorStart(ref currentBounds, lineOffset - OM.Major(desiredSize) - lineSpacing);

if (lineNeedsReposition)
Expand Down
1 change: 1 addition & 0 deletions test/ModernWpfTestApp/RepeaterTestUIPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
AutomationProperties.Name="Basic Demo">
Basic Demo
</Button>
<Button x:Name="uniformGridLayoutDemo" AutomationProperties.Name="UniformGridLayoutDemo">UniformGridLayout testing</Button>
</StackPanel>

</controls:LayoutPanel>
Expand Down
5 changes: 5 additions & 0 deletions test/ModernWpfTestApp/RepeaterTestUIPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public RepeaterTestUIPage()
Frame.NavigateWithoutAnimation(typeof(BasicDemo));
};

uniformGridLayoutDemo.Click += delegate
{
Frame.NavigateWithoutAnimation(typeof(UniformGridLayoutDemo));
};

itemsSourceDemo.Click += delegate
{
Frame.NavigateWithoutAnimation(typeof(ElementsInItemsSourcePage));
Expand Down
39 changes: 39 additions & 0 deletions test/ModernWpfTestApp/Samples/UniformGridLayoutDemo.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ui:Page
x:Class="MUXControlsTestApp.Samples.UniformGridLayoutDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:controls="clr-namespace:ModernWpf.Controls;assembly=ModernWpf.Controls"
xmlns:sys="clr-namespace:System;assembly=mscorlib">

<Page.Resources>
<!-- The Layout specifications used: -->
<controls:UniformGridLayout x:Key="UniformGridLayout"
MinRowSpacing="8" MinColumnSpacing="8"
MaximumRowsOrColumns="4"/>

<DataTemplate x:Key="SimpleElementTemplate" DataType="sys:String">
<Grid Background="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
Width="100"
Height="100">
<TextBlock Text="{Binding}"
FontSize="20"/>
</Grid>
</DataTemplate>
</Page.Resources>
<StackPanel Orientation="Horizontal">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
AutomationProperties.Name="RepeaterScrollViewer"
MaxHeight="500">
<controls:ItemsRepeater x:Name="UniformGridRepeater"
Layout="{StaticResource UniformGridLayout}"
ItemTemplate="{StaticResource SimpleElementTemplate}"/>
</ScrollViewer>
<StackPanel>
<Button AutomationProperties.Name="GetRepeaterActualHeightButton"
Click="GetRepeaterActualHeightButtonClick">Get actual Repeater height</Button>
<TextBlock x:Name="RepeaterActualHeightLabel" AutomationProperties.Name="RepeaterActualHeightLabel"/>
</StackPanel>
</StackPanel>
</ui:Page>
26 changes: 26 additions & 0 deletions test/ModernWpfTestApp/Samples/UniformGridLayoutDemo.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Collections.Generic;
using System.Linq;
using System.Windows;

namespace MUXControlsTestApp.Samples
{
public sealed partial class UniformGridLayoutDemo
{
public IEnumerable<int> collection;

public UniformGridLayoutDemo()
{
collection = Enumerable.Range(0, 40);
this.InitializeComponent();
UniformGridRepeater.ItemsSource = collection;
}

public void GetRepeaterActualHeightButtonClick(object sender, RoutedEventArgs e)
{
RepeaterActualHeightLabel.Text = UniformGridRepeater.ActualHeight.ToString();
}
}
}

0 comments on commit d724375

Please sign in to comment.