diff options
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs new file mode 100644 index 00000000..54a8eb9a --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs @@ -0,0 +1,85 @@ +using System.Diagnostics; +using System.Reflection; + +using Xamarin.Forms.CustomAttributes; + +namespace Xamarin.Forms.Controls +{ + [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", + Font = Font.BoldSystemFontOfSize(50), + 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 + } + }; + } + } + +} |