2016-03-22 23:02:25 +03:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Xamarin.Forms.CustomAttributes;
|
2016-04-26 18:20:55 +03:00
|
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
2016-11-15 22:39:23 +03:00
|
|
|
|
#if UITEST
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Xamarin.Forms.Core.UITests;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
namespace Xamarin.Forms.Controls
|
|
|
|
|
{
|
2016-11-15 22:39:23 +03:00
|
|
|
|
#if UITEST
|
|
|
|
|
[Category(UITestCategories.BoxView)]
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
[Issue (IssueTracker.Github, 1075, "Does not update Color", PlatformAffected.Android | PlatformAffected.WinPhone)]
|
|
|
|
|
public class Issue1075 : ContentPage
|
|
|
|
|
{
|
|
|
|
|
// Issue1075
|
|
|
|
|
// BoxView doesn't update color
|
|
|
|
|
public Issue1075 ()
|
|
|
|
|
{
|
|
|
|
|
Label header = new Label
|
|
|
|
|
{
|
|
|
|
|
Text = "Picker",
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning disable 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
Font = Font.BoldSystemFontOfSize(50),
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning restore 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
HorizontalOptions = LayoutOptions.Center
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Picker picker = new Picker
|
|
|
|
|
{
|
|
|
|
|
Title = "Color",
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (string color in new string[]
|
|
|
|
|
{
|
|
|
|
|
"Aqua", "Black", "Blue", "Fuschia",
|
|
|
|
|
"Gray", "Green", "Lime", "Maroon",
|
|
|
|
|
"Navy", "Olive", "Purple", "Red",
|
|
|
|
|
"Silver", "Teal", "White", "Yellow"
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
picker.Items.Add(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create BoxView for displaying pickedColor
|
|
|
|
|
BoxView boxView = new BoxView
|
|
|
|
|
{
|
|
|
|
|
WidthRequest = 150,
|
|
|
|
|
HeightRequest = 150,
|
|
|
|
|
HorizontalOptions = LayoutOptions.Center,
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var button = new Button {
|
|
|
|
|
Text = "Change to blue",
|
|
|
|
|
Command = new Command (() => boxView.BackgroundColor = Color.Aqua)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
picker.SelectedIndexChanged += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
if (picker.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
boxView.Color = Color.Default;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string selectedItem = picker.Items[picker.SelectedIndex];
|
|
|
|
|
FieldInfo colorField = typeof(Color).GetTypeInfo().GetDeclaredField(selectedItem);
|
|
|
|
|
boxView.Color = (Color)colorField.GetValue(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Accomodate iPhone status bar.
|
|
|
|
|
Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 0);
|
|
|
|
|
|
|
|
|
|
// Build the page.
|
|
|
|
|
Content = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
Children =
|
|
|
|
|
{
|
|
|
|
|
header,
|
|
|
|
|
picker,
|
|
|
|
|
boxView,
|
|
|
|
|
button
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|