1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
using System.Diagnostics;
using System.Reflection;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls
{
#if UITEST
[Category(UITestCategories.BoxView)]
#endif
[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",
#pragma warning disable 618
Font = Font.BoldSystemFontOfSize(50),
#pragma warning restore 618
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 = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 0) : new Thickness(10, 0);
// Build the page.
Content = new StackLayout
{
Children =
{
header,
picker,
boxView,
button
}
};
}
}
}
|