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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:55:05+00:00 2026-06-08T13:55:05+00:00

I am not sure if this is even possible, but here is my setup:

  • 0

I am not sure if this is even possible, but here is my setup:

I have a customized textbox that is only meant to deal with hotkey selection. In here I have a DependencyProperty that is for the SelectedHotKey.

Then I have a custom control that is a label, the textbox, and a button. This control also exposes a DependencyProperty of the same name as the TextBox, and it merely ties to the TextBox via:

SelectedHotKey="{Binding ElementName=Main, Path=SelectedHotKey, Mode=TwoWay}"

With this dependency property, I am looking to set the textbox’s SelectedHotKey, which will change the Text appropriately.

I am then using that user control and binding to my ViewModel.

I have all of this working except for the initialization case.

When my ViewModel is already set up and passed to the UserControl in the binding, that initial setter does not even get hit, so it does not propogate down through my controls. I thought about putting in a PropertyMetaData method, however that is a static method and I do not have access to my instance textboxes.

Any ideas? Let me know if I need to clarify further.

  • 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-08T13:55:07+00:00Added an answer on June 8, 2026 at 1:55 pm

    Don’t put code logic in the CLR property wrapping the dependency property. As you have already seen, there is no guarantee they will ever be called since the framework can call SetValue directly on the dependency property.

    You’re in the right track: you have to use the dependency property metadata. Access the instance by using the first parameter of the property changed callback.

    DependencyProperty SomeProperty = DependencyProperty.Register(
        "Some",
        propertyType,
        ownerType,
        new FrameworkPropertyMetadata(defaultValue, OnSomePropertyChanged));
    
    static void OnSomePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
        // "d" is your instance here, cast it to the required type
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if this is even possible but here goes: Currently I have
I'm not sure if this is even possible but here we go. I have
I'm not sure this is even possible, but here goes: I have a class
I'm not sure if this is even possible, but here goes: I have a
I'm not even sure this is possible to do efficiently, but here's my problem:
I'm not sure if this is even remotely possible but here it goes: is
I'm not sure this is even possible but I know if it is, the
I'm not sure if this is even possible, but is there a way to
Ok, not sure if this is even possible, but I want to change the
Hello! I'm not even sure if this is possible, but hopefully it is in

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.