我正在嘗試在 WPF 應用程序中將a 綁定Dictionary到我的。ComboBoxSortedDictionary<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。
代碼隱藏中 ComboBox SelectedValuePath 的問題
幕布斯6054654
2023-08-20 09:56:34