diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Core/Interactivity/DataTrigger.cs | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Core/Interactivity/DataTrigger.cs')
-rw-r--r-- | Xamarin.Forms.Core/Interactivity/DataTrigger.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/Interactivity/DataTrigger.cs b/Xamarin.Forms.Core/Interactivity/DataTrigger.cs new file mode 100644 index 00000000..e27ec134 --- /dev/null +++ b/Xamarin.Forms.Core/Interactivity/DataTrigger.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using Xamarin.Forms.Xaml; + +namespace Xamarin.Forms +{ + [ContentProperty("Setters")] + public sealed class DataTrigger : TriggerBase, IValueProvider + { + public DataTrigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new BindingCondition(), targetType) + { + } + + public BindingBase Binding + { + get { return ((BindingCondition)Condition).Binding; } + set + { + if (((BindingCondition)Condition).Binding == value) + return; + if (IsSealed) + throw new InvalidOperationException("Can not change Binding once the Trigger has been applied."); + OnPropertyChanging(); + ((BindingCondition)Condition).Binding = value; + OnPropertyChanged(); + } + } + + public new IList<Setter> Setters + { + get { return base.Setters; } + } + + public object Value + { + get { return ((BindingCondition)Condition).Value; } + set + { + if (((BindingCondition)Condition).Value == value) + return; + if (IsSealed) + throw new InvalidOperationException("Can not change Value once the Trigger has been applied."); + OnPropertyChanging(); + ((BindingCondition)Condition).Value = value; + OnPropertyChanged(); + } + } + + object IValueProvider.ProvideValue(IServiceProvider serviceProvider) + { + var valueconverter = serviceProvider.GetService(typeof(IValueConverterProvider)) as IValueConverterProvider; + (Condition as BindingCondition).ValueConverter = valueconverter; + + return this; + } + } +}
\ No newline at end of file |