- using Telerik 10.1.0, Maui 9.0.50
- this issue was very obvious when using Windows as resizing the app's window made the layouts render incorrectly at certain sizes
- reproduced this on Windows, but unsure if the same will apply to other platforms.
- if the calculations are incorrect across platforms the same issues could happen on Android and iOS if you hit the issue straight away at your device screen size or if you use resizeable windows (which I cannot test myself).
- I've created a couple of test scenarios, one where the item size (255) is defined via its Width (253) and a Margin (1,1,1,1), and another where the Margin is 0 and the Width is 255.
- see attached screenshots of app running on my pc (Windows 11 build 10.0.26100.3476)
Repro steps:
- Create a blank telerik project (I've not used shell);
- Update maui to 9.0.50 (for more relevance with current code);
- Replace the contents of MainPage.xaml with the xaml shown below;
- Remove unnecessary code from MainPage.xaml.cs to allow app to build and run;
- OBSERVE:
- Test 1.2 fails - items are shown on a single row when they should not fit.
- Test 1.3 fails - items are shown on a single row when they should not fit, and the wrap layout is extended to two rows.
- Test 2.1 fails - items are show on two rows when they should fit a single one.
Xaml to use
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Button">
<Setter Property="WidthRequest" Value="253" />
<Setter Property="HeightRequest" Value="77" />
<Setter Property="Background" Value="Green" />
<Setter Property="TextColor" Value="White" />
<Setter Property="Margin" Value="1,1,1,1" />
<Setter Property="Text" Value="Witdh 253, Margin 1,1,1,1" />
</Style>
<Style x:Key="NoMargin" TargetType="Button">
<Setter Property="WidthRequest" Value="255" />
<Setter Property="Margin" Value="0" />
<Setter Property="Text" Value="Witdh 255, Margin 0" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView>
<VerticalStackLayout Margin="30,0" VerticalOptions="Center">
<!-- FIRST TEST -->
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 765 should fit all its items on a single row" />
<telerik:RadWrapLayout Background="DarkGreen" StretchLastChild="False" WidthRequest="765">
<Button />
<Button />
<Button />
</telerik:RadWrapLayout>
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 764.5 shows items in a single row (when they shouldn't fit)" />
<telerik:RadWrapLayout Background="DarkRed" StretchLastChild="False" WidthRequest="764.5">
<Button />
<Button />
<Button />
</telerik:RadWrapLayout>
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 764.4 shows items in a single row (when they shouldn't fit) and presents a blank row" />
<telerik:RadWrapLayout Background="DarkRed" StretchLastChild="False" WidthRequest="764.4">
<Button />
<Button />
<Button />
</telerik:RadWrapLayout>
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 764.3 shows items in two rows, as expected" />
<telerik:RadWrapLayout Background="DarkGreen" StretchLastChild="False" WidthRequest="764.3">
<Button />
<Button />
<Button />
</telerik:RadWrapLayout>
<!-- SECOND TEST -->
<Label Margin="30" HorizontalOptions="Center" Text="Second test" />
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 765 should fit all its items on a single row, but doesn't" />
<telerik:RadWrapLayout Background="DarkRed" StretchLastChild="False" WidthRequest="765">
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
</telerik:RadWrapLayout>
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 764.5 shows items in two rows" />
<telerik:RadWrapLayout Background="DarkGreen" StretchLastChild="False" WidthRequest="764.5">
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
</telerik:RadWrapLayout>
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 764.4 shows items in two rows" />
<telerik:RadWrapLayout Background="DarkGreen" StretchLastChild="False" WidthRequest="764.4">
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
</telerik:RadWrapLayout>
<Label Margin="30" HorizontalOptions="Center" Text="The layout below at width 764.3 shows items in two rows" />
<telerik:RadWrapLayout Background="DarkGreen" StretchLastChild="False" WidthRequest="764.3">
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
<Button Style="{StaticResource NoMargin}" />
</telerik:RadWrapLayout>
</VerticalStackLayout>
</ScrollView>