About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

3 Responses to #164 – Overriding Metadata for an Inherited Dependency Property

  1. Pingback: #165 – Overriding Metadata Can Result in Merged Metadata « 2,000 Things You Should Know About WPF

  2. Tengo says:

    Having a subclass of lets say DataGrid with the following call in the static constructor:

    ItemsSourceProperty.OverrideMetadata(typeof(ChildDataGrid), new FrameworkPropertyMetadata((PropertyChangedCallback)null, OnCoerceItemSoureProperty));

    Causes both the DataGrid and the Subclass OnCoerceItemSourceProperty callbacks to fire.

    So like the comment before me, I don’t think its fair to say overriding metadata “CoerceValueCallback replaces the existing one” because the parents callback is unfazed.

    • Sean says:

      It should get replaced. That’s the behavior that I see and what is documented in http://msdn.microsoft.com/en-us/library/ms752375.aspx (look for “CoerceValueCallback” implementations are replaced).

      Have you tried setting up your coerce value callback to have a new/unique name, to double-check that the parent’s callback is still getting called? How are you verifying that it’s getting called–setting a breakpoint in DataGrid?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: