Thursday, 26 July 2012

Nullable Dependency Properties and Binding


Author’s Note: If you’re here just for a solution and are not interested in the extraneous bits, click here to jump to the workaround details.

First, some background…

Let’s say you’re building a user control and one of your control’s properties needs to be a three state boolean (true, false, null).

No sweat, we’ll just create a nullable boolean (bool?) dependency property:
1
2
3
4
5
public static readonly DependencyProperty ValueProperty =
    DependencyProperty.Register("Value",
        typeof(bool?),
        typeof(TestControl),
        new PropertyMetadata(null));

Read full article here

No comments:

Post a Comment

Web Informer Button