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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:54:44+00:00 2026-05-16T02:54:44+00:00

I have a dependency property on a control which is a custom class. Now

  • 0

I have a dependency property on a control which is a custom class.

Now is there an event that gets raised BEFORE the value is being changed?

I know that OnPropertyChanged is raised after the property has already changed.

I need some event before so that I can cancel the changing….in order to preserve the state of the control.

I cannot set back the dependency property back to its old value as that will mean that I lose state in the control.

Thanks!

  • 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-16T02:54:45+00:00Added an answer on May 16, 2026 at 2:54 am

    If its your DependencyProperty, you can use the ValidateValueCallback to validate the incoming value and reject it, if its not as you desire.

    In the following example, only values greater than 0 will be accepted:

    public int Test {
        get { return (int)GetValue(TestProperty); }
        set { SetValue(TestProperty, value); }
    }
    
    
    public static readonly DependencyProperty TestProperty =
        DependencyProperty.Register("Test", typeof(int), typeof(YourClass), 
        new UIPropertyMetadata(0), delegate(object v) { 
          return ((int)v) > 0; // Here you can check the value set to the dp
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dependency property (Foreground) on a custom control which is inheriting from
I have a user control which I would like to add a dependency property
I have a wpf control named DataPicker which has a dependency property named SelectedDate.
I have a control with a dependency property which I want to pass which
I have a class derived from slider which uses a custom control template and
I have made a control which has a property that is calculated by using
I have the following dependency property inside a class: class FooHolder { public static
I have this DependencyProperty which holds an entity with a property that is a
I have the following simple custom control that I have defined for a Windows
Here's the situation: I have a custom TextBox control that contains multiple other TextBox

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.