Skip to content

Commit

Permalink
[iOS] Fix double margin on Image
Browse files Browse the repository at this point in the history
(cherry picked from commit b39f9e6)
  • Loading branch information
jeromelaban authored and mergify-bot committed Dec 17, 2019
1 parent 4ee18c5 commit 1933069
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ImageTests\Image_Margin.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ImageTests\Image_Stretch_Algmnt_Inf_Vertical.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -3008,6 +3012,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ImageTests\Image_ImageSource_PixelSize.xaml.cs">
<DependentUpon>Image_ImageSource_PixelSize.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ImageTests\Image_Margin.xaml.cs">
<DependentUpon>$fileinputname$.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ImageTests\Image_Stretch_Algmnt_Inf_Horizontal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ImageTests\Image_Stretch_Algmnt_Inf_Vertical.xaml.cs">
<DependentUpon>Image_Stretch_Algmnt_Inf_Vertical.xaml</DependentUpon>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<Page
x:Class="UITests.Shared.Windows_UI_Xaml_Controls.ImageTests.Image_Margin"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Shared.Windows_UI_Xaml_Controls.ImageTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Grid Grid.Row="0"
Grid.Column="0"
Background="Orange"
Width="100"
Height="100">
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/ingredient3.png"
Stretch="Uniform"
Margin="0,0" />
</StackPanel>
</Grid>

<Grid Grid.Row="0"
Grid.Column="1"
Background="Orange"
Width="100"
Height="100">
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/ingredient3.png"
Stretch="Uniform"
Margin="20,0" />
</StackPanel>
</Grid>

<Grid Grid.Row="0"
Grid.Column="2"
Background="Orange"
Width="100"
Height="100">
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/ingredient3.png"
Stretch="Uniform"
Margin="0,20" />
</StackPanel>
</Grid>

<Grid Grid.Row="1"
Grid.Column="0"
Background="Orange"
Width="100"
Height="100">
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/ingredient3.png"
Stretch="Uniform"
Margin="20,0,0,0" />
</StackPanel>
</Grid>

<Grid Grid.Row="1"
Grid.Column="1"
Background="Orange"
Width="100"
Height="100">
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/ingredient3.png"
Stretch="Uniform"
Margin="0,20,0,0" />
</StackPanel>
</Grid>

<Grid Grid.Row="1"
Grid.Column="2"
Background="Orange"
Width="100"
Height="100">
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/ingredient3.png"
Stretch="Uniform"
Margin="0,0,20,0" />
</StackPanel>
</Grid>

<Grid Grid.Row="2"
Grid.Column="0"
Background="Orange"
Width="100"
Height="100">
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/ingredient3.png"
Stretch="Uniform"
Margin="0,0,0,20" />
</StackPanel>
</Grid>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Uno.UI.Samples.Controls;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace UITests.Shared.Windows_UI_Xaml_Controls.ImageTests
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[SampleControlInfo]
public sealed partial class Image_Margin : Page
{
public Image_Margin()
{
this.InitializeComponent();
}
}
}
5 changes: 4 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ protected Size MeasureChild(View view, Size slotSize)
return ret;
}

if (frameworkElement != null && !(frameworkElement is FrameworkElement))
if (frameworkElement != null
&& !(frameworkElement is FrameworkElement)
&& !(frameworkElement is Image)
)
{
// For IFrameworkElement implementers that are not FrameworkElements, the constraint logic must
// be performed by the parent. Otherwise, the native element will take the size it needs without
Expand Down

0 comments on commit 1933069

Please sign in to comment.