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 8739483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:56:46+00:00 2026-06-13T10:56:46+00:00

I found this on MSDN: A dependency property value can be set by referencing

  • 0

I found this on MSDN:

A dependency property value can be set by referencing a resource. Resources are typically specified as the Resources property value of a page root element, or of the application (these locations enable the most convenient access to the resource). The following example shows how to define a SolidColorBrush resource.

XAML:

<DockPanel.Resources>
    <SolidColorBrush x:Key="MyBrush" Color="Gold"/>
</DockPanel.Resources>

Once the resource is defined, you can reference the resource and use it to provide a property value:

<Button Background="{DynamicResource MyBrush}" Content="I am gold" />

This particular resource is referenced as a DynamicResource Markup Extension . To use a dynamic resource reference, you must be setting to a dependency property, so it is specifically the dynamic resource reference usage that is enabled by the WPF property system.

My questions are:

  1. StaticResource is not considered Dependency Property? If yes why?
  2. Does not belongs to WPF Property System?

Also can you give me an example how to implement default value using Dependency Property?

  • 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-06-13T10:56:47+00:00Added an answer on June 13, 2026 at 10:56 am

    DynamicResource is used for setting only dependency property values.

    By contrast StaticResource can be used pratically everywhere. You can use it to set a dependency property value but not only. For example, you can also define an element as resource as use it inside a panel by StaticResource, such as in the code

    <Window>
       <Window.Resources>
           <Button Content="btnStaticResource" x:Key="myBtn" />
       </Window.Resources>
    
       <Grid> 
          <StaticResource ResourceKey="myBtn" /> 
       </Grid>
    </Window>
    

    Concerning your question 1, a resource is not a dependency property, irrespective if you refer to it using StaticResource or DynamicResource markup extension.

    A resource in WPF can be about anything, a .NET object, a font, an image, a color, a string etc.
    The concept of resource is not related to the concept of dependency property.

    A dependency property is a new type of property introduced by WPF. A dependency property value depends on multiple sources according to a fixed hierarchie (for details msdn).

    Concerning your question 2, yes, the concept of StaticResource is part of the WPF resource system.

    Finally, for defining the default value of a dependency property see the following code:

    public static readonly DependencyProperty AlphaProperty = DependencyProperty.Register   ("Alpha", typeof(int), typeof(MyButton), new FrameworkPropertyMetadata(255, FrameworkPropertyMetadataOptions.AffectsRender));
    

    Here is defined a dependency property named Alpha, of type int and with default value 255.

    I hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this article on MSDN talking about Cross-page posting . I never worked
I am learning how to draw GUI's with GDI/GDI+, i found this http://msdn.microsoft.com/en-us/library/windows/desktop/dd756596(v=vs.85).aspx#step_2__declare_that_the_application_is_dpi-aware Does
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
I found a topic on MSDN that talks that yes, this is possible. I
found this regex: insert every 10 characters: $text = preg_replace(|(.{10})|u, \${1}. , $text); can
I've found this MSDN article that explains how to monitor processes and services with
I found this: http://msdn.microsoft.com/en-us/library/vslangproj80.reference3%28VS.80%29.aspx what I have in mind is that many of the
I found this article regarding Linq-to-SQL and SQL Server connection pooling: MSDN Blog From
In msdn i found this - http://msdn.microsoft.com/en-us/library/ff650218.aspx but I don't know where to find
I'm trying to use WMPlib.dll to play files so I found this: http://msdn.microsoft.com/en-us/library/windows/desktop/dd562692%28v=vs.85%29.aspx As

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.