Kyle Delaney
Kyle Delaney

Reputation: 12274

How can a static property be set to a value only for a specific element?

If Stylus.IsPressAndHoldEnabled is a static property of the Stylus class, shouldn't its value be global? How can a value be set to it just for one element, like a button?

<Setter Property="Stylus.IsPressAndHoldEnabled" Value="False"/>

This is of course a general question that applies to more than just this class and property. I'm just trying to understand how WPF works. I'd appreciate any links that touch on this topic.

Upvotes: 1

Views: 141

Answers (1)

BradleyDotNET
BradleyDotNET

Reputation: 61369

These properties are Dependency Properties and Attached Properties (a special case of dependency properties). They are technically static, but what you don't see are generated calls to GetValue and SetValue that do take the control instance in question. The static piece is really just setting up the property so the framework knows about it.

You can actually see these calls in the normal properties generated by the propdp snippet (note that these properties are never called by the framework, they are just for your convenience).

Upvotes: 3

Related Questions