我正在尝试在 WPF 应用程序中将a 绑定Dictionary到我的。ComboBox
SortedDictionary<string, string> result = new SortedDictionary<string, string>();
((ComboBox)frameWorkElement).ItemsSource = result;
((ComboBox)frameWorkElement).DisplayMemberPath = "Value";
((ComboBox)frameWorkElement).SelectedValuePath = "Key";
((ComboBox)frameWorkElement).MinWidth = 200;
frameWorkElement.Name = "ListOfValues";
var binding = new Binding("ComboBoxSourceValue")
{
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
};
binding.Mode = BindingMode.TwoWay;
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
frameWorkElement.SetBinding(ComboBox.TextProperty, (BindingBase)binding);
在 UI 方面,值已正确绑定。但在提交操作中,我只能看到 value ( Display value) 以及所选值的Key。
慕的地6264312
相关分类