96e881550d3087af2a8751bb61bd5ca69ea76d6a
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / Interactivity / DataTrigger.cs
1 using System;
2 using System.Collections.Generic;
3 using Tizen.NUI.Xaml;
4
5 namespace Tizen.NUI.Binding
6 {
7     [ContentProperty("Setters")]
8     [ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.PassthroughValueProvider")]
9     [AcceptEmptyServiceProvider]
10     internal sealed class DataTrigger : TriggerBase, IValueProvider
11     {
12         public DataTrigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new BindingCondition(), targetType)
13         {
14         }
15
16         public BindingBase Binding
17         {
18             get { return ((BindingCondition)Condition).Binding; }
19             set
20             {
21                 if (((BindingCondition)Condition).Binding == value)
22                     return;
23                 if (IsSealed)
24                     throw new InvalidOperationException("Can not change Binding once the Trigger has been applied.");
25                 OnPropertyChanging();
26                 ((BindingCondition)Condition).Binding = value;
27                 OnPropertyChanged();
28             }
29         }
30
31         public new IList<Setter> Setters
32         {
33             get { return base.Setters; }
34         }
35
36         public object Value
37         {
38             get { return ((BindingCondition)Condition).Value; }
39             set
40             {
41                 if (((BindingCondition)Condition).Value == value)
42                     return;
43                 if (IsSealed)
44                     throw new InvalidOperationException("Can not change Value once the Trigger has been applied.");
45                 OnPropertyChanging();
46                 ((BindingCondition)Condition).Value = value;
47                 OnPropertyChanged();
48             }
49         }
50
51         object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
52         {
53             //This is no longer required
54             return this;
55         }
56     }
57 }