1 namespace System.Activities.Presentation.PropertyEditing {
7 /// Concrete implementation of PropertyValueSource for a PropertyEntry that represents a Dependency Property
9 [Fx.Tag.XamlVisible(false)]
10 public class DependencyPropertyValueSource : PropertyValueSource
13 private static DependencyPropertyValueSource _dataBound;
14 private static DependencyPropertyValueSource _systemResource;
15 private static DependencyPropertyValueSource _localDynamicResource;
16 private static DependencyPropertyValueSource _localStaticResource;
17 private static DependencyPropertyValueSource _templateBinding;
18 private static DependencyPropertyValueSource _customMarkupExtension;
19 private static DependencyPropertyValueSource _local;
20 private static DependencyPropertyValueSource _defaultValue;
21 private static DependencyPropertyValueSource _inherited;
23 private readonly ValueSource _source;
26 /// The property is set to a value that is a data binding.
28 public static DependencyPropertyValueSource DataBound {
30 if (_dataBound == null) _dataBound = new DependencyPropertyValueSource(ValueSource.DataBound);
36 /// The property is set to a system resource.
38 public static DependencyPropertyValueSource SystemResource {
40 if (_systemResource == null) _systemResource = new DependencyPropertyValueSource(ValueSource.SystemResource);
41 return _systemResource;
46 /// The property is set to a DynamicResource reference.
48 public static DependencyPropertyValueSource LocalDynamicResource {
50 if (_localDynamicResource == null) _localDynamicResource = new DependencyPropertyValueSource(ValueSource.LocalDynamicResource);
51 return _localDynamicResource;
56 /// The property is set to a StaticResource reference.
58 public static DependencyPropertyValueSource LocalStaticResource {
60 if (_localStaticResource == null) _localStaticResource = new DependencyPropertyValueSource(ValueSource.LocalStaticResource);
61 return _localStaticResource;
66 /// The property is set to a TemplateBinding markup extension.
68 public static DependencyPropertyValueSource TemplateBinding {
70 if (_templateBinding == null) _templateBinding = new DependencyPropertyValueSource(ValueSource.TemplateBinding);
71 return _templateBinding;
76 /// The property is set to a custom markup extension.
78 public static DependencyPropertyValueSource CustomMarkupExtension {
80 if (_customMarkupExtension == null) _customMarkupExtension = new DependencyPropertyValueSource(ValueSource.CustomMarkupExtension);
81 return _customMarkupExtension;
86 /// The property is set to a local value.
88 public static DependencyPropertyValueSource Local {
90 if (_local == null) _local = new DependencyPropertyValueSource(ValueSource.Local);
96 /// The property is set to its default value (ie. it does not have a value set in XAML and
97 /// it's not inheriting any value from its parent)
99 public static DependencyPropertyValueSource DefaultValue {
101 if (_defaultValue == null) _defaultValue = new DependencyPropertyValueSource(ValueSource.DefaultValue);
102 return _defaultValue;
107 /// The property is inherited from a parent property.
109 public static DependencyPropertyValueSource Inherited {
111 if (_inherited == null) _inherited = new DependencyPropertyValueSource(ValueSource.Inherited);
116 private DependencyPropertyValueSource(ValueSource source) {
121 /// Read-only property that returns true if the property is set to an expression
122 /// i.e. (DataBound, LocalDynamicResource, LocalStaticResource, SystemResource, TemplateBinding or
123 /// CustomMarkupExtension)
125 public bool IsExpression {
127 return _source == ValueSource.DataBound
128 || _source == ValueSource.LocalDynamicResource
129 || _source == ValueSource.LocalStaticResource
130 || _source == ValueSource.SystemResource
131 || _source == ValueSource.TemplateBinding
132 || _source == ValueSource.CustomMarkupExtension;
137 /// Read-only property that returns true if the property is set to a system or local resource
139 public bool IsResource {
141 return _source == ValueSource.SystemResource
142 || _source == ValueSource.LocalDynamicResource
143 || _source == ValueSource.LocalStaticResource;
148 /// Read-only property that returns true if the property is set to a data binding expression.
150 public bool IsDataBound {
151 get { return _source == ValueSource.DataBound; }
155 /// Read-only property that returns true if the property is set to a system resource
157 public bool IsSystemResource {
158 get { return _source == ValueSource.SystemResource; }
162 /// Read-only property that returns true if the property is set to a DynamicResource
164 public bool IsLocalResource {
166 return _source == ValueSource.LocalDynamicResource
167 || _source == ValueSource.LocalStaticResource;
172 /// Read-only property that returns true if the property is set to a TemplateBinding markup extension
174 public bool IsTemplateBinding {
175 get { return _source == ValueSource.TemplateBinding; }
179 /// Read-only property that returns true if the property is set to a custom markup extension.
181 public bool IsCustomMarkupExtension {
182 get { return _source == ValueSource.CustomMarkupExtension; }
186 /// Read-only property that returns true if the property is set to a local value.
188 public bool IsLocal {
189 get { return _source == ValueSource.Local; }
193 /// Read-only property that returns true if the property is set to its default value
194 /// (ie. it does not have a value set in XAML and it's not inheriting any value from
197 public bool IsDefaultValue {
198 get { return _source == ValueSource.DefaultValue; }
202 /// Read-only property that returns true if the property is inherited.
204 public bool IsInherited {
205 get { return _source == ValueSource.Inherited; }
208 private enum ValueSource {
211 LocalDynamicResource,
214 CustomMarkupExtension,