我有一些代码可以获取组合框的绑定表达式
bindingExpression = ((ComboBox)(((Grid)(control.Content)).Children[0])).GetBindingExpression( ComboBox.SelectedValueProperty );
组合框在 xaml 中定义
<ComboBox Style="{StaticResource UiEditorComboBoxStyle}"
Name="comboBox_Business"
DisplayMemberPath="Value.Name"
SelectedValuePath="Value.BusinessId"
>
<ComboBox.SelectedValue>
<Binding Path="entity.BusinessId" UpdateSourceTrigger="Explicit" ValidatesOnDataErrors="True" ValidatesOnExceptions="True" Mode="TwoWay">
<Binding.ValidationRules>
<validators:ValidationRule_SelectedItem NotSelectedErrorMessage="A Business must be selected"
NotSelectedErrorMessageTranslationKey="BusinessMustBeSelected" />
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedValue>
</ComboBox>
当我打电话
bindingExpression.UpdateSource()
我得到一个“指定的演员表无效”异常。我猜这与属性(Guid)的类型有关,但我不知道如何处理它。
组合框值绑定到字典
任何指针?
干杯,
Ĵ