WPF: Get Property that a control is Bound to in code behind

Posted by Richard on Stack Overflow See other posts from Stack Overflow or by Richard
Published on 2010-05-04T17:34:49Z Indexed on 2010/05/04 17:38 UTC
Read the original article Hit count: 475

Filed under:
|
|

Hi all,

I am trying to find a way to get the Property to which a control is bound (in c#).

If I have the following:

<dxe:ComboBoxEdit DisplayMember="Name" ItemsSource="{Binding Path=NameOptions, Mode=OneTime}" SelectedItem="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" />

I am now trying to get the location to which the SelectedItem is bound to, i.e. the result should be "Name". Then in code I need to do some stuff with that ViewModel Property. Issue is that I can't just hard code this as it is a generic method that needs to work with each control on the form.

Thanks, Richard

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpf-binding