tags:

views:

20

answers:

1

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  A: 
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);

HTH,
Kent

Kent Boogaart
That's great and very fast and userfulI finally got like thisvar binding = BindingOperations.GetBinding(a, CheckBox.IsCheckedProperty); string property = binding.Path.Path.ToString();
Sathish