summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/Interactivity/DataTrigger.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core/Interactivity/DataTrigger.cs')
-rw-r--r--Xamarin.Forms.Core/Interactivity/DataTrigger.cs57
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