Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 9355d6b

Browse files
mjmostachettirmarinhosamhouts
authored
Including file for testing issue 9451 (#11567)
Co-authored-by: Rui Marinho <[email protected]> Co-authored-by: Samantha Houts <[email protected]> fixes #9451
1 parent 3ebae5d commit 9355d6b

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Xamarin.Forms.Internals;
5+
using Xamarin.Forms.CustomAttributes;
6+
using System.ComponentModel;
7+
using System.Threading.Tasks;
8+
9+
namespace Xamarin.Forms.Controls.Issues
10+
{
11+
[Issue(IssueTracker.Github, 9451,
12+
"[Bug] RelativeLayout Constraint can not go back to zero", PlatformAffected.All)]
13+
public class Issue9451 : TestContentPage
14+
{
15+
public StackLayout StackLayout { get; set; }
16+
public Button TriggerButton { get; set; }
17+
18+
protected override void Init()
19+
{
20+
var relativeLayout = new RelativeLayout() { WidthRequest = 400, HeightRequest = 400 };
21+
StackLayout = new StackLayout() { BackgroundColor = Color.Red };
22+
23+
TriggerButton = new Button() { Text = "Set View Width To Zero" };
24+
25+
StackLayout.Children.Add(TriggerButton);
26+
27+
relativeLayout.Children.Add(StackLayout,
28+
Xamarin.Forms.Constraint.Constant(0),
29+
Xamarin.Forms.Constraint.Constant(0),
30+
Xamarin.Forms.Constraint.RelativeToParent(x => x.Width / 2),
31+
Xamarin.Forms.Constraint.RelativeToParent(y => y.Height));
32+
33+
Content = relativeLayout;
34+
}
35+
36+
protected override void OnAppearing()
37+
{
38+
base.OnAppearing();
39+
40+
TriggerButton.Clicked += Button_Clicked;
41+
}
42+
43+
protected override void OnDisappearing()
44+
{
45+
base.OnDisappearing();
46+
47+
TriggerButton.Clicked -= Button_Clicked;
48+
}
49+
50+
private void Button_Clicked(object sender, EventArgs e)
51+
{
52+
RelativeLayout.SetWidthConstraint(StackLayout, Xamarin.Forms.Constraint.Constant(0.0));
53+
}
54+
}
55+
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@
14401440
<Compile Include="$(MSBuildThisFileDirectory)Issue11291.cs" />
14411441
<Compile Include="$(MSBuildThisFileDirectory)Issue11244.cs" />
14421442
<Compile Include="$(MSBuildThisFileDirectory)Issue11272.cs" />
1443+
<Compile Include="$(MSBuildThisFileDirectory)Issue9451.cs" />
14431444
<Compile Include="$(MSBuildThisFileDirectory)Issue11374.xaml.cs" />
14441445
<Compile Include="$(MSBuildThisFileDirectory)Issue11430.cs" />
14451446
<Compile Include="$(MSBuildThisFileDirectory)Issue11247.cs" />

0 commit comments

Comments
 (0)