• .NET

    WPF: Read-only Dependency Properties

    August 22, 2008 Share
    Yup, awkward creatures but they do exist! :) To be honest I came across these only recently and decided to share this (potentially) valuable information as well -- you cannot use it if you do not know it's there. Why do we need read-only dependency properties? There is a certain brand of dependency properties within the WPF framework that are used primarily for state determination. Often multiple conditions affect certain control state thus calculating and setting the state value directly is not feasible and generally leads to unpredictable and inconsistent results. Here is an example -- the UIElement.IsMouseOver dependency property (a common property...
  • .NET

    WPF: The Static Nature of Dependency Properties

    July 25, 2008 Share
    With dependency properties being so heavily used across the WPF platform, there is a good chance that sooner or later you will get bitten by this issue my colleague Hristo Deshev and I were debugging not long ago. Some heads-up can't really hurt anybody so here it is;). We will declare a simple class Foo with a single collection dependency property (note that this is a reference type). We will also supply our brand new property with a default value through the convenient DependecyProperty.Register(...) method: Let us put our class to the test by creating two Foo instances and adding a single item...