[WPF] Fix bug : StackLayout VerticalOptions = LayoutOptions.End is not working
This commit is contained in:
Коммит
67a72326e0
|
@ -0,0 +1,49 @@
|
||||||
|
using Xamarin.Forms.CustomAttributes;
|
||||||
|
using Xamarin.Forms.Internals;
|
||||||
|
|
||||||
|
#if UITEST
|
||||||
|
using Xamarin.UITest;
|
||||||
|
using NUnit.Framework;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Xamarin.Forms.Controls.Issues
|
||||||
|
{
|
||||||
|
[Preserve(AllMembers = true)]
|
||||||
|
[Issue(IssueTracker.Github, 2394, "[WPF] StackLayout VerticalOptions = LayoutOptions.End is not working", PlatformAffected.WPF)]
|
||||||
|
public class Issue2394 : TestContentPage
|
||||||
|
{
|
||||||
|
protected override void Init()
|
||||||
|
{
|
||||||
|
if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
|
||||||
|
Padding = new Thickness(0, 0, 0, 60);
|
||||||
|
|
||||||
|
var stack = new StackLayout { VerticalOptions = LayoutOptions.End };
|
||||||
|
Button b1 = new Button { Text = "Boring", HeightRequest = 100, MinimumHeightRequest = 50 };
|
||||||
|
Button b2 = new Button
|
||||||
|
{
|
||||||
|
Text = "Exciting!",
|
||||||
|
VerticalOptions = LayoutOptions.FillAndExpand,
|
||||||
|
HorizontalOptions = LayoutOptions.CenterAndExpand
|
||||||
|
};
|
||||||
|
Button b3 = new Button { Text = "Amazing!", VerticalOptions = LayoutOptions.FillAndExpand };
|
||||||
|
Button b4 = new Button { Text = "Meh", HeightRequest = 100, MinimumHeightRequest = 50 };
|
||||||
|
b1.Clicked += (sender, e) => {
|
||||||
|
b1.Text = "clicked1";
|
||||||
|
};
|
||||||
|
b2.Clicked += (sender, e) => {
|
||||||
|
b2.Text = "clicked2";
|
||||||
|
};
|
||||||
|
b3.Clicked += (sender, e) => {
|
||||||
|
b3.Text = "clicked3";
|
||||||
|
};
|
||||||
|
b4.Clicked += (sender, e) => {
|
||||||
|
b4.Text = "clicked4";
|
||||||
|
};
|
||||||
|
stack.Children.Add(b1);
|
||||||
|
stack.Children.Add(b2);
|
||||||
|
stack.Children.Add(b3);
|
||||||
|
stack.Children.Add(b4);
|
||||||
|
Content = stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -294,6 +294,7 @@
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1864.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Issue1864.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2104.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Issue2104.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1908.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Issue1908.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Issue2394.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2983.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Issue2983.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2963.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Issue2963.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2981.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Issue2981.cs" />
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
using WControl = System.Windows.Controls.Control;
|
using WControl = System.Windows.Controls.Control;
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.WPF
|
namespace Xamarin.Forms.Platform.WPF
|
||||||
|
@ -126,7 +120,6 @@ namespace Xamarin.Forms.Platform.WPF
|
||||||
for (var i = 0; i < _elementChangedHandlers.Count; i++)
|
for (var i = 0; i < _elementChangedHandlers.Count; i++)
|
||||||
_elementChangedHandlers[i](this, args);
|
_elementChangedHandlers[i](this, args);
|
||||||
|
|
||||||
UpdateRequests();
|
|
||||||
ElementChanged?.Invoke(this, e);
|
ElementChanged?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,10 +127,10 @@ namespace Xamarin.Forms.Platform.WPF
|
||||||
{
|
{
|
||||||
if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
|
if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
|
||||||
UpdateEnabled();
|
UpdateEnabled();
|
||||||
else if (e.PropertyName == Frame.HeightRequestProperty.PropertyName)
|
else if (e.PropertyName == Frame.HeightProperty.PropertyName)
|
||||||
UpdateRequests();
|
UpdateHeight();
|
||||||
else if (e.PropertyName == Frame.WidthRequestProperty.PropertyName)
|
else if (e.PropertyName == Frame.WidthProperty.PropertyName)
|
||||||
UpdateRequests();
|
UpdateWidth();
|
||||||
else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
|
else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
|
||||||
UpdateBackground();
|
UpdateBackground();
|
||||||
else if (e.PropertyName == View.HorizontalOptionsProperty.PropertyName || e.PropertyName == View.VerticalOptionsProperty.PropertyName)
|
else if (e.PropertyName == View.HorizontalOptionsProperty.PropertyName || e.PropertyName == View.VerticalOptionsProperty.PropertyName)
|
||||||
|
@ -201,13 +194,20 @@ namespace Xamarin.Forms.Platform.WPF
|
||||||
control.UpdateDependencyColor(WControl.BackgroundProperty, Element.BackgroundColor);
|
control.UpdateDependencyColor(WControl.BackgroundProperty, Element.BackgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdateRequests()
|
protected virtual void UpdateHeight()
|
||||||
{
|
{
|
||||||
if (Control == null || Element == null)
|
if (Control == null || Element == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Control.Width = Element.WidthRequest >= 0 ? Element.WidthRequest : Double.NaN;
|
Control.Height = Element.Height > 0 ? Element.Height : Double.NaN;
|
||||||
Control.Height = Element.HeightRequest >= 0 ? Element.HeightRequest : Double.NaN;
|
}
|
||||||
|
|
||||||
|
protected virtual void UpdateWidth()
|
||||||
|
{
|
||||||
|
if (Control == null || Element == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Control.Width = Element.Width > 0 ? Element.Width : Double.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdateNativeWidget()
|
protected virtual void UpdateNativeWidget()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче