How to propagate Dependency Property PropertyChanged event through binding in WPF?
up vote
0
down vote
favorite
I have a UserControl, which contains a DependencyProperty (string) in it's code behind. The property works fine, I am setting it from the code behind, and a label on the UserControl displays it's content properly via Binding. There is no Binding exception. The problem is: If i try to Bind something from outside to the UserControl's property, the Binding works, i can see the label displaying the string, but if the code behind changes the string, i cant receive the event at the outside Property. I even put a breakpoint in it's setter, but it never occurs. So, the question is: how do I propagate the dependency property's changed event to the outside property?
c# .net wpf
New contributor
add a comment |
up vote
0
down vote
favorite
I have a UserControl, which contains a DependencyProperty (string) in it's code behind. The property works fine, I am setting it from the code behind, and a label on the UserControl displays it's content properly via Binding. There is no Binding exception. The problem is: If i try to Bind something from outside to the UserControl's property, the Binding works, i can see the label displaying the string, but if the code behind changes the string, i cant receive the event at the outside Property. I even put a breakpoint in it's setter, but it never occurs. So, the question is: how do I propagate the dependency property's changed event to the outside property?
c# .net wpf
New contributor
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example
– ASh
Nov 19 at 12:08
The getter and setter for a dependency property are not used for bindings (this is why your breakpoints don't get hit). You have to pass aPropertyChangedCallback
as part ofFrameworkPropertyMetadata
in theDependencyProperty.Register
function. See this answer for more information and an example.
– Bradley Uffner
Nov 19 at 12:52
Possible duplicate of How To Raise Property Changed events on a Dependency Property?
– Bradley Uffner
Nov 19 at 12:54
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a UserControl, which contains a DependencyProperty (string) in it's code behind. The property works fine, I am setting it from the code behind, and a label on the UserControl displays it's content properly via Binding. There is no Binding exception. The problem is: If i try to Bind something from outside to the UserControl's property, the Binding works, i can see the label displaying the string, but if the code behind changes the string, i cant receive the event at the outside Property. I even put a breakpoint in it's setter, but it never occurs. So, the question is: how do I propagate the dependency property's changed event to the outside property?
c# .net wpf
New contributor
I have a UserControl, which contains a DependencyProperty (string) in it's code behind. The property works fine, I am setting it from the code behind, and a label on the UserControl displays it's content properly via Binding. There is no Binding exception. The problem is: If i try to Bind something from outside to the UserControl's property, the Binding works, i can see the label displaying the string, but if the code behind changes the string, i cant receive the event at the outside Property. I even put a breakpoint in it's setter, but it never occurs. So, the question is: how do I propagate the dependency property's changed event to the outside property?
c# .net wpf
c# .net wpf
New contributor
New contributor
New contributor
asked Nov 19 at 12:04
Bence Mányoki
1
1
New contributor
New contributor
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example
– ASh
Nov 19 at 12:08
The getter and setter for a dependency property are not used for bindings (this is why your breakpoints don't get hit). You have to pass aPropertyChangedCallback
as part ofFrameworkPropertyMetadata
in theDependencyProperty.Register
function. See this answer for more information and an example.
– Bradley Uffner
Nov 19 at 12:52
Possible duplicate of How To Raise Property Changed events on a Dependency Property?
– Bradley Uffner
Nov 19 at 12:54
add a comment |
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example
– ASh
Nov 19 at 12:08
The getter and setter for a dependency property are not used for bindings (this is why your breakpoints don't get hit). You have to pass aPropertyChangedCallback
as part ofFrameworkPropertyMetadata
in theDependencyProperty.Register
function. See this answer for more information and an example.
– Bradley Uffner
Nov 19 at 12:52
Possible duplicate of How To Raise Property Changed events on a Dependency Property?
– Bradley Uffner
Nov 19 at 12:54
1
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example
– ASh
Nov 19 at 12:08
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example
– ASh
Nov 19 at 12:08
The getter and setter for a dependency property are not used for bindings (this is why your breakpoints don't get hit). You have to pass a
PropertyChangedCallback
as part of FrameworkPropertyMetadata
in the DependencyProperty.Register
function. See this answer for more information and an example.– Bradley Uffner
Nov 19 at 12:52
The getter and setter for a dependency property are not used for bindings (this is why your breakpoints don't get hit). You have to pass a
PropertyChangedCallback
as part of FrameworkPropertyMetadata
in the DependencyProperty.Register
function. See this answer for more information and an example.– Bradley Uffner
Nov 19 at 12:52
Possible duplicate of How To Raise Property Changed events on a Dependency Property?
– Bradley Uffner
Nov 19 at 12:54
Possible duplicate of How To Raise Property Changed events on a Dependency Property?
– Bradley Uffner
Nov 19 at 12:54
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Bence Mányoki is a new contributor. Be nice, and check out our Code of Conduct.
Bence Mányoki is a new contributor. Be nice, and check out our Code of Conduct.
Bence Mányoki is a new contributor. Be nice, and check out our Code of Conduct.
Bence Mányoki is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374261%2fhow-to-propagate-dependency-property-propertychanged-event-through-binding-in-wp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example
– ASh
Nov 19 at 12:08
The getter and setter for a dependency property are not used for bindings (this is why your breakpoints don't get hit). You have to pass a
PropertyChangedCallback
as part ofFrameworkPropertyMetadata
in theDependencyProperty.Register
function. See this answer for more information and an example.– Bradley Uffner
Nov 19 at 12:52
Possible duplicate of How To Raise Property Changed events on a Dependency Property?
– Bradley Uffner
Nov 19 at 12:54