我试图找到一种方法来获取控件绑定的属性(在c#中).
如果我有以下内容:
<dxe:ComboBoxEdit DisplayMember="Name" ItemsSource="{Binding Path=NameOptions, Mode=OneTime}" SelectedItem="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" />
我现在正试图获取SelectedItem绑定的位置,即结果应该是"Name".然后在代码中我需要用ViewModel属性做一些事情.问题是我不能只对它进行硬编码,因为它是一种需要处理表单上每个控件的通用方法.
谢谢,理查德
Mar*_*iec 16
我认为应该这样做:
BindingExpression be = BindingOperations.GetBindingExpression((FrameworkElement)yourComboBox, ((DependencyProperty)Button.SelectedItemProperty));
string Name = be.ParentBinding.Path.Path;
| 归档时间: | 
 | 
| 查看次数: | 8765 次 | 
| 最近记录: |