summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/SettersExtensions.cs
blob: 8f94e6d81d18a9198a247593172293f2a7f3e08c (plain)
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
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) });
		}
	}
}