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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:56:42+00:00 2026-06-03T11:56:42+00:00

I am learning dependency properties. I read many posts & books but still I

  • 0

I am learning dependency properties. I read many posts & books but still I am not clear.

The program shown below is which I wrote to learn. Some error in that, please help in resolving. I have questions.

  1. The main use of custom Dependency property element is for the notification of change?
  2. I found an ‘IsDefaultProperty’ code for Button in a WPF text book. It means ‘IsDefault‘ property is a dependency property?
  3. Why they shown that code? It means, internally, in Button class, its defined like that?
    (They showed internal code?) or they showed how to define as custom?

Here is my code:

namespace DependencyProperties
{
    public class Contact
    {
        private int id=100;
        private string name="shri";
        public static readonly DependencyProperty IsPresentProperty;

        public int ID
        {
            get { return id; }
        }
        public string NAME
        {
            get { return name; }
        }

        static Contact()
        {
            IsPresentProperty = DependencyProperty.Register("IsPresent", typeof(bool),typeof(Contact),new FrameworkPropertyMetadata(false,new PropertyChangedCallback(OnIsPresentChanged)));
        }

        public bool Present
        {
            get { return (bool)GetValue(Contact.IsPresentProperty); }
            set { SetValue(Contact.IsPresentProperty, value); }
        }

        private static void OnIsPresentChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {  

        }
    }
}

And I see the error:

> Error: GetValue and SetValue does not exist in the current context
  • 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-03T11:56:43+00:00Added an answer on June 3, 2026 at 11:56 am

    The main use of custom Dependency property element is for the
    notification of change?

    No, that can also be arranged by having the class implement INotifyPropertyChanged as well. Dependency properties to provide change notifications, but the real rationale is something different. See Why dependency properties? and How is the WPF property system economical?

    I found an ‘IsDefaultProperty’ code for Button in a WPF text book. It
    means ‘IsDefault’ property is a dependency property?

    Yes. Naming a field “FooBarProperty” is the WPF convention for defining dependency properties; you can check the docs for IsDefaultProperty to see that it’s indeed a dependency property, and even the IsDefault documentation has a section called “dependency property information”.

    Why they shown that code? It means, internally, in Button class, its
    defined like that? (They showed internal code?) or they showed how to
    define as custom?

    I ‘m not sure what “that” code is, but yes, the property is almost certainly defined like that in Button (“almost” because I ‘m not sure what you are referring to).

    Error: GetValue and SetValue does not exist in the current context

    That’s because you are not deriving from DependencyObject.

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

Sidebar

Related Questions

I am learning to use dependency injection with ninject. Most of the properties and
Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring
A question about Guice. I'm still learning it, but I can understand the fundamentals.
Still learning Objective-C / iPhone SDK here. I think I know why this wasn't
Just learning about Dependency Injection and Prism... It seems just asking around alot of
There are already some questions about dependency managers here, but it seems to me
I am trying to become a good programming citizen through learning more about Dependency
I've been learning IoC, Dependency Injection etc. and enjoying the process. The benefits of
I am learning java for 3 months and sometimes i can not understand the
I have gotten rid of a circular dependence but am still having issues with

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.