title: Delayed "rendering" of WPF/Silverlight Dependency Properties?
body: <p>Is there a way to know the first time a Dependency Property is accessed through XAML binding so I can actually "render" the value of the property when needed?</p>
  
  <p>I have an object (class derived from Control) that has several PointCollection Dependency Properties that may contain 100's or 1000's of points. Each property may arrange the points differently for use in different types shapes (Polyline, Polygon, etc - its more complicated then this, but you get the idea). Via a Template different XAML objects use TemplateBinding to access these properties. Since my object uses a Template I never know what XAML shapes may be in use for my object - so I never know what Properties they may or may not bind to. I'd like to only fill-in these PointCollections when they are actually needed.</p>
  
  <p>Normally in .NET I'd but some logic in the Property's getter, but these are bypassed by XAML data binding.</p>
  
  <p>I need a WPF AND Silverlight compatible solution.</p>
  
  <p>I'd love a solution that avoids any additional complexities for the users of my object.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>One way that I've found to do this is using <a href="http://blogs.msdn.com/delay/archive/2008/05/04/ivalueconverter-the-swiss-army-knife-of-bindings-propertyviewer-sample-is-a-wpf-silverlight-visualization-and-debugging-aid.aspx" rel="nofollow noreferrer">Value Converters</a>. In my situation I had multiple point collections. There was a main dep. property that contained the usual shape of the data. Two alternate shapes were needed for reuse in other areas/contexts.</p>
  
  <p>At first I had 3 dep. props. But, I could have just had one property (the usual shape) and used a value converted to transform the points into my other 2 desired shapes. Doing this I only make the one set of points in the control. The expense of transforming points to the secondary shapes is only incurred when used. Now my main control doesn't need to anticipate how data needs to look for every possible template thrown at the control - now its the template designers problem.</p>
  
  <hr>
  
  <p><strong>Update 2</strong></p>
  
  <p>Certainly INotifyPropertyChanged and regular properties are the recommended way to handle this.</p>