summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2017-03-03 06:31:46 -0600
committerRui Marinho <me@ruimarinho.net>2017-03-03 12:31:46 +0000
commit8871077f115e7ef4d15efaa418fd718089db42c7 (patch)
tree91faf77329b6c1be984f36665ea80d6ae6a57589 /Xamarin.Forms.Controls.Issues
parent38c0b34e91e2148e78704432afec6b086c9fc0c9 (diff)
downloadxamarin-forms-8871077f115e7ef4d15efaa418fd718089db42c7.tar.gz
xamarin-forms-8871077f115e7ef4d15efaa418fd718089db42c7.tar.bz2
xamarin-forms-8871077f115e7ef4d15efaa418fd718089db42c7.zip
[WinRT/UWP] Make TextBox better respect background color changes via behaviors (#749)
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44955.cs81
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
2 files changed, 82 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44955.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44955.cs
new file mode 100644
index 00000000..a30a65bd
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44955.cs
@@ -0,0 +1,81 @@
+using System.Diagnostics;
+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.Bugzilla, 44955, "[WinRT/UWP] Setting Entry BackgroundColor via Behavior results in sticky unfocused background color", PlatformAffected.WinRT)]
+ public class Bugzilla44955 : TestContentPage
+ {
+ Entry _validationEntry;
+ protected override void Init()
+ {
+ _validationEntry = new Entry();
+ _validationEntry.Behaviors.Add(new NonEmptyStringValidator());
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new Label
+ {
+ Text = "The first entry should have a red background only when it is empty, regardless of focus (due to an attached behavior). The second has a set background color, the third is default, and the last is default, but disabled."
+ },
+ _validationEntry,
+ new Entry
+ {
+ BackgroundColor = Color.MediumPurple
+ },
+ new Entry(),
+ new Entry
+ {
+ IsEnabled = false
+ },
+ new Button
+ {
+ Text = "Change background of first label to yellow",
+ Command = new Command(() => _validationEntry.BackgroundColor = Color.Yellow)
+ }
+ }
+ };
+ }
+
+ protected override void OnDisappearing()
+ {
+ base.OnDisappearing();
+ _validationEntry.Behaviors.Clear();
+ }
+
+ class NonEmptyStringValidator : Behavior<Entry>
+ {
+ protected override void OnAttachedTo(Entry bindable)
+ {
+ bindable.TextChanged += HandleTextChanged;
+ Validate(bindable, bindable.Text);
+ }
+
+ protected override void OnDetachingFrom(Entry bindable)
+ {
+ bindable.TextChanged -= HandleTextChanged;
+ }
+
+ void HandleTextChanged(object sender, TextChangedEventArgs e)
+ {
+ Validate((Entry)sender, e.NewTextValue);
+ }
+
+ void Validate(Entry entry, string text)
+ {
+ if (text == null)
+ entry.BackgroundColor = Color.Red;
+ else
+ entry.BackgroundColor = text.Trim() != "" ? Color.Default : Color.Red;
+ }
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 1093f1b0..0deca6b6 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -164,6 +164,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44338.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla45027.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla45330.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44955.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla45743.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla46494.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44476.cs" />