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

  • SEARCH
  • Home
  • 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 6348145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:21:58+00:00 2026-05-24T21:21:58+00:00

I read this in the following link:- http://www.informit.com/articles/article.aspx?p=688529&seqNum=2 However, because GetValue and SetValue internally

  • 0

I read this in the following link:-

http://www.informit.com/articles/article.aspx?p=688529&seqNum=2

However, because GetValue and SetValue internally use an efficient sparse storage system and because IsDefaultProperty is a static field (rather than an instance field), the dependency property implementation saves per-instance memory compared to a typical .NET property. If all the properties on WPF controls were wrappers around instance fields (as most .NET properties are), they would consume a significant amount of memory because of all the local data attached to each instance.

But eventually they are getting stored somewhere, how does it saves memory consumption ?

  • 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-24T21:21:58+00:00Added an answer on May 24, 2026 at 9:21 pm

    See the following link: Dependency Properties.

    What is declared by an object as a dependency property is in fact
    nothing more than an identifier. This static "property" is really a
    key which associates an object with a specific storage identifier. For
    example graphical objects have a Background property that can be set
    explicitly or through the use of templates or styles..

    As long as a Dependency Property uses its default state (which is very common), it won’t take up any additional memory since the default value will be used. The default value isn’t stored per instance, it is stored per Dependency Property and it’s set by metadata.

    Example, notice how Brushes.Black is set as the default value

    public static readonly DependencyProperty ForegroundProperty =
        DependencyProperty.Register(
            "Foreground",
            typeof(Brush),
            typeof(TextElement),
            new FrameworkPropertyMetadata(Brushes.Black, ...));
    

    Think of it this way: Say you have four TextBlocks in Xaml

    <StackPanel>
        <TextBlock .../>
        <TextBlock .../>
        <TextBlock .../>
        <TextBlock Foreground="Green" .../>
    </StackPanel>
    

    The three TextBlocks at the top have Foreground set to Black although you have never explicitly set it to Black. They are using their default value. So for the Foreground property for the three TextBlocks above, you only need one field (since it is a static field).

    For the forth TextBlock though, you have explicitly set Foreground to Green, so that value is inserted into a dictionary as the local value for Foreground on this instance and thus requires additional memory (also, it will end up at place number 3 in the list below, overriding Setters, Triggers etc).

    Also, see the following post by Josh Smith, it’s a good read: Demystifying dependency properties

    There is a well-defined set of rules which is used internally by WPF
    to figure out what the real value of a DP is. Here is a brief summary
    of the rules of precedence used when resolving the value of a DP (read
    more about it here):

    1. Property system coercion
    2. Active animations, or animations with a Hold behavior
    3. Local value
    4. TemplatedParent template
    5. Style triggers
    6. Template triggers
    7. Style setters
    8. Theme style
    9. Inheritance
    10. Default value from dependency property metadata

    Edit: To answer the comment from Duane

    If you explicitly set the value to the same value as the default value, it will still get stored as the local value. This can easily be verified with the following Xaml.

    Both TextBlocks will have Foreground set to Black, but the later has a local value set. The Style will only be able to set Foreground on the first TextBlock and not the later since Style setters has lower priority than local value.

    <StackPanel>
        <StackPanel.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Foreground" Value="Green"/>
            </Style>
        </StackPanel.Resources>
        <TextBlock Text="Displays in Green"/>
        <TextBlock Foreground="Black" Text="Displays in Black"/>
    </StackPanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a long time I had the following bookmark in Firefox: http://www.codeguru.com/csharp/.net/net_general/keyboard/article.php/c4639 I know
Firstly, I have read these: (1) http://www.gaiagps.com/news/article/iOS5%20Breaks%20Data%20Storage%20and%20Crushes%20My%20Soul (2) http://iphoneincubator.com/blog/data-management/local-file-storage-in-ios-5 (I can not submit more
The following quote is from this link: http://apidocs.meego.com/1.2-preview/qtmobility/qgeopositioninfosource.html#createDefaultSource Creates and returns a position source
following this link i was able to load and read pixels from a .gif.
I am trying to read the public wall posts of: http://www.facebook.com/TheWalkingDeadAMC It is possible
I am trying to get the source code for the following page: http://www.amazon.com/gp/offer-listing/082470732X/ref=dp_olp_0?ie=UTF8&redirect=true&condition=all (Please
I am following an intro tutorial http://www.linuxinsight.com/files/alp/alp-ch01-getting-started.pdf . I have created the source files
I have uploaded my code to pastebin, this is the link: http://pastebin.com/wBu9PP2x When i
http://www.therapistsurvey.com/vignette0/vig01 Notice that once you click the See Parents' Response, the link will trigger
I read This article and i found it interesting. To sum it up for

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.