0

I have a code snippet as below

<CheckBox Name="cb" Margin="1,2,1,0"  IsChecked="{Binding Path=IsManager}" IsEnabled="True"/>

Consider I don't know which property is bind to IsChecked property. I want to get programattically know the binding information of IsChecked property. How can do I that?

1
  • Do you mean in C#, you want to get the binding for the IsChecked property of CheckBox cb? Commented Aug 26, 2010 at 11:56

1 Answer 1

2
var binding = BindingOperations.GetBinding(cb, CheckBox.IsCheckedProperty);

Or you can get the actual expression generated for that particular instance of the binding:

var bindingExpression = BindingOperations.GetBindingExpression(cb, CheckBox.IsCheckedProperty);
Sign up to request clarification or add additional context in comments.

1 Comment

That's great and very fast and userful I finally got like this var binding = BindingOperations.GetBinding(a, CheckBox.IsCheckedProperty); string property = binding.Path.Path.ToString();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.