第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

代碼隱藏中 ComboBox SelectedValuePath 的問題

代碼隱藏中 ComboBox SelectedValuePath 的問題

C#
幕布斯6054654 2023-08-20 09:56:34
我正在嘗試在 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。
查看完整描述

1 回答

?
慕的地6264312

TA貢獻1817條經驗 獲得超6個贊

frameWorkElement.SetBinding(ComboBox.SelectedValueProperty, binding);

DataContext如果的ComboBox或父元素被設置為具有名為“ComboBoxSourceValue”的源屬性的類的實例,則應該可以工作string

SelectedValuePathKeyValuePair<TKey, TValue>指的是中的屬性SortedDictionary。您仍然需要將該值綁定到源屬性。


查看完整回答
反對 回復 2023-08-20
  • 1 回答
  • 0 關注
  • 145 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號