11using System ;
22using System . Collections . Generic ;
3+ using System . Collections . Immutable ;
34using System . Linq ;
45using System . Text ;
56using Windows . UI . Xaml ;
@@ -51,7 +52,7 @@ public sealed partial class DependencyProperty
5152
5253 private static int _globalId ;
5354
54- private DependencyProperty ( string name , Type propertyType , Type ownerType , PropertyMetadata defaultMetadata , bool attached )
55+ private DependencyProperty ( string name , Type propertyType , Type ownerType , PropertyMetadata defaultMetadata , bool attached , IEnumerable < DependencyProperty > dependentProperties )
5556 {
5657 _name = name ;
5758 _propertyType = propertyType ;
@@ -70,6 +71,13 @@ private DependencyProperty(string name, Type propertyType, Type ownerType, Prope
7071
7172 // Improve the performance of the hash code by
7273 CachedHashCode = _name . GetHashCode ( ) ^ ownerType . GetHashCode ( ) ;
74+
75+ DependentProperties = dependentProperties . ToImmutableArray ( ) ;
76+ }
77+
78+ private DependencyProperty ( string name , Type propertyType , Type ownerType , PropertyMetadata defaultMetadata , bool attached ) :
79+ this ( name , propertyType , ownerType , defaultMetadata , attached , Enumerable . Empty < DependencyProperty > ( ) )
80+ {
7381 }
7482
7583 /// <summary>
@@ -95,12 +103,13 @@ internal bool IsDependencyObjectCollection
95103 /// <param name="name">The name of the property.</param>
96104 /// <param name="propertyType">The type of the property</param>
97105 /// <param name="ownerType">The owner type of the property</param>
98- /// <param name="typeMetadata">The metadata to use when creating the property</param>
106+ /// <param name="defaultMetadata">The metadata to use when creating the property</param>
107+ /// <param name="dependentProperties">Other properties whose bindings need to update before the new property's bindings</param>
99108 /// <returns>A dependency property instance</returns>
100109 /// <exception cref="InvalidOperationException">A property with the same name has already been declared for the ownerType</exception>
101- public static DependencyProperty Register ( string name , Type propertyType , Type ownerType , PropertyMetadata typeMetadata )
110+ internal static DependencyProperty Register ( string name , Type propertyType , Type ownerType , PropertyMetadata defaultMetadata , IEnumerable < DependencyProperty > dependentProperties )
102111 {
103- var newProperty = new DependencyProperty ( name , propertyType , ownerType , typeMetadata , attached : false ) ;
112+ var newProperty = new DependencyProperty ( name , propertyType , ownerType , defaultMetadata , attached : true , dependentProperties ) ;
104113
105114 try
106115 {
@@ -117,6 +126,18 @@ public static DependencyProperty Register(string name, Type propertyType, Type o
117126 return newProperty ;
118127 }
119128
129+ /// <summary>
130+ /// Registers a dependency property on the specified <paramref name="ownerType"/>.
131+ /// </summary>
132+ /// <param name="name">The name of the property.</param>
133+ /// <param name="propertyType">The type of the property</param>
134+ /// <param name="ownerType">The owner type of the property</param>
135+ /// <param name="typeMetadata">The metadata to use when creating the property</param>
136+ /// <returns>A dependency property instance</returns>
137+ /// <exception cref="InvalidOperationException">A property with the same name has already been declared for the ownerType</exception>
138+ public static DependencyProperty Register ( string name , Type propertyType , Type ownerType , PropertyMetadata typeMetadata )
139+ => Register ( name , propertyType , ownerType , typeMetadata , Enumerable . Empty < DependencyProperty > ( ) ) ;
140+
120141 /// <summary>
121142 /// Registers a dependency property on the specified <paramref name="ownerType"/>.
122143 /// </summary>
@@ -191,6 +212,8 @@ internal int CachedHashCode
191212 get ;
192213 }
193214
215+ internal ImmutableArray < DependencyProperty > DependentProperties { get ; } = ImmutableArray < DependencyProperty > . Empty ;
216+
194217 /// <summary>
195218 /// Specifies a static value that is used by the dependency property system rather than null to indicate that
196219 /// the property exists, but does not have its value set by the dependency property system.
0 commit comments