blob: e27ec1347f2554a0a20ed76eebf0abda5dfa6480 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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;
}
}
}
|