diff options
Diffstat (limited to 'Xamarin.Forms.Core/SettersExtensions.cs')
-rw-r--r-- | Xamarin.Forms.Core/SettersExtensions.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/SettersExtensions.cs b/Xamarin.Forms.Core/SettersExtensions.cs new file mode 100644 index 00000000..8f94e6d8 --- /dev/null +++ b/Xamarin.Forms.Core/SettersExtensions.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using Xamarin.Forms.Internals; + +namespace Xamarin.Forms +{ + public static class SettersExtensions + { + public static void Add(this IList<Setter> setters, BindableProperty property, object value) + { + setters.Add(new Setter { Property = property, Value = value }); + } + + public static void AddBinding(this IList<Setter> setters, BindableProperty property, Binding binding) + { + if (binding == null) + throw new ArgumentNullException("binding"); + + setters.Add(new Setter { Property = property, Value = binding }); + } + + public static void AddDynamicResource(this IList<Setter> setters, BindableProperty property, string key) + { + if (string.IsNullOrEmpty(key)) + throw new ArgumentNullException("key"); + setters.Add(new Setter { Property = property, Value = new DynamicResource(key) }); + } + } +}
\ No newline at end of file |