We need to redefine the metadata DependencyPropertyfor our subclass. Now I know that I can use OverrideMetadataand specify a completely new object FrameworkPropertyMetadata, but for the most part I want these new metadata to be exactly the same as existing metadata, with the exception of one additional flag (in particular AffectsMeasure)
My thought is to get the existing metadata, create a new metadata object, manually copy all the elements from the old to the new (it does not support Clone), changing the one I want, then use the new one in the OverrideMetadata call. But da **, this is a lot of work for something else, so simple!
Did I miss something?
EDIT
First of all, I meant AffectsMeasurenot AffectsRender(which I changed above)
BUT ... I just found out that our class already has a flag set AffectsMeasurefor the property Width. The real problem is with containers ListBox(e.g. a ListBoxItem), and MeasureOverrideonly called once when it is initialized first.
Since this is a technically unrelated question, I will start a new one and close this one.
Here is a link to a new question:
Why doesn't ListBoxItem call MeasureOverride when its width changes?
source
share