diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-08-16 12:10:32 -0600 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-08-16 11:10:32 -0700 |
commit | 30c0dcb949186c21c60c4c9ddf8a581d40a43662 (patch) | |
tree | 17a196012b9d4044f78cc0acbe9aa137d10f2b25 /Xamarin.Forms.Platform.WP8/BrushHelpers.cs | |
parent | 966683a807f68f302e8f121279387109f2a4a73b (diff) | |
download | xamarin-forms-30c0dcb949186c21c60c4c9ddf8a581d40a43662.tar.gz xamarin-forms-30c0dcb949186c21c60c4c9ddf8a581d40a43662.tar.bz2 xamarin-forms-30c0dcb949186c21c60c4c9ddf8a581d40a43662.zip |
Fix Entry/SearchBar color issues (#306)
* Fix disappearing Entry text on UWP Anniversary Edition
Fix background color reversion bug in UWP Phone
Move SearchBar styling on UWP to its own file
Make foreground/background color changes on UWP SearchBar/Entry consistent
Fix SearchBar color toggle bug on WP8
* Temporarily moving SDK target to previous version
* Fix build error on OSX
Diffstat (limited to 'Xamarin.Forms.Platform.WP8/BrushHelpers.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WP8/BrushHelpers.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WP8/BrushHelpers.cs b/Xamarin.Forms.Platform.WP8/BrushHelpers.cs new file mode 100644 index 00000000..993b23f4 --- /dev/null +++ b/Xamarin.Forms.Platform.WP8/BrushHelpers.cs @@ -0,0 +1,37 @@ +using System; +using System.Windows.Media; + +namespace Xamarin.Forms.Platform.WinPhone +{ + internal static class BrushHelpers + { + /// <summary> + /// Handles the logic for setting a Xamarin.Forms Color for a Brush + /// while caching the original default brush + /// </summary> + /// <param name="color">The target Xamarin.Forms.Color</param> + /// <param name="defaultbrush">The renderer's cache for the default brush</param> + /// <param name="getter">Delegate for retrieving the Control's current Brush</param> + /// <param name="setter">Delegate for setting the Control's Brush</param> + public static void UpdateColor(Color color, ref Brush defaultbrush, Func<Brush> getter, Action<Brush> setter) + { + if (color.IsDefault) + { + if (defaultbrush == null) + { + return; + } + + setter(defaultbrush); + return; + } + + if (defaultbrush == null) + { + defaultbrush = getter(); + } + + setter(color.ToBrush()); + } + } +} |