Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6671523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:23:54+00:00 2026-05-26T03:23:54+00:00

We need to override a DependencyProperty ‘s metadata for our subclass. Now I know

  • 0

We need to override a DependencyProperty‘s metadata for our subclass. Now I know that I can use OverrideMetadata and specify entirely new FrameworkPropertyMetadata object, but for the most part I want this new metadata to be exactly the same as the existing metadata except with one additional flag set (specifically AffectsMeasure)

My thought is to get the existing metadata, create a new metadata object, hand-copy all the members over from the old to the new (it doesn’t support Clone) changing the one I want, then use the new one in the OverrideMetadata call. But da** that is a lot of work for something otherwise so simple!

Am I missing something here?

EDIT

First things first, I meant AffectsMeasure not AffectsRender (which I’ve changed above),

BUT… I just found out our class already has the AffectsMeasure flag set for the Width property. The real issue is for containers of a ListBox (e.g. a ListBoxItem) the MeasureOverride is only called once, when first initialized.

Since this is technically an unrelated question, I’ll start a new one and close this one.

Here’s the link to the new question:

Why is a ListBoxItem not calling MeasureOverride when its width is changed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:23:55+00:00Added an answer on May 26, 2026 at 3:23 am

    Copying the metadata from the base class’ metadata is definitely the way to go. Though unfortunately the FrameworkPropertyMetadata class doesn’t expose the flags as they given, they are exposed as bool properties to indicate their state. To get those values back as a FrameworkPropertyMetadataOptions, you’ll have to go through the associated properties and read them back as one.

    static DerivedClass()
    {
        var oldMeta = (FrameworkPropertyMetadata)BaseClass.SomeProperty.GetMetadata(typeof(BaseClass));
        var flags = GetFlags(oldMeta);
    
        // change the values as needed
        var meta = new FrameworkPropertyMetadata(
            oldMeta.DefaultValue,
            flags,
            oldMeta.PropertyChangedCallback,
            oldMeta.CoerceValueCallback,
            oldMeta.IsAnimationProhibited,
            oldMeta.DefaultUpdateSourceTrigger
        );
    
        BaseClass.SomeProperty.OverrideMetadata(typeof(DerivedClass), meta);
    }
    
    static FrameworkPropertyMetadataOptions GetFlags(FrameworkPropertyMetadata metadata)
    {
        FrameworkPropertyMetadataOptions flags = FrameworkPropertyMetadataOptions.None;
        if (metadata.AffectsArrange)
            flags |= FrameworkPropertyMetadataOptions.AffectsArrange;
        if (metadata.AffectsMeasure)
            flags |= FrameworkPropertyMetadataOptions.AffectsMeasure;
        if (metadata.AffectsParentArrange)
            flags |= FrameworkPropertyMetadataOptions.AffectsParentArrange;
        if (metadata.AffectsParentMeasure)
            flags |= FrameworkPropertyMetadataOptions.AffectsParentMeasure;
        if (metadata.AffectsRender)
            flags |= FrameworkPropertyMetadataOptions.AffectsRender;
        if (metadata.BindsTwoWayByDefault)
            flags |= FrameworkPropertyMetadataOptions.BindsTwoWayByDefault;
        if (metadata.Inherits)
            flags |= FrameworkPropertyMetadataOptions.Inherits;
        if (metadata.Journal)
            flags |= FrameworkPropertyMetadataOptions.Journal;
        if (metadata.IsNotDataBindable)
            flags |= FrameworkPropertyMetadataOptions.NotDataBindable;
        if (metadata.OverridesInheritanceBehavior)
            flags |= FrameworkPropertyMetadataOptions.OverridesInheritanceBehavior;
        if (metadata.SubPropertiesDoNotAffectRender)
            flags |= FrameworkPropertyMetadataOptions.SubPropertiesDoNotAffectRender;
        return flags;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to override Backbone.sync to allow PUT the problem is i don't know
I have read that when you override Equals on an class/object you need to
According to Apple's docs, Subclasses need not override -[UIView drawRect:] if the subclass is
I cannot find a solution for that, I need to override a previously set
guys please let me know, in real world why we need to override equals
I'm working on custom control that I can use for interactions within my app
I need to override devise in a such way that when user sign up
I am using $(#formid).serialize() that returns a string and I need to override one
I need to override a function in this file: app/code/core/Mage/Core/functions.php The problem is that
I'm working with DelayedJob and I need to override a method that I thought

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.