2
我有一個ComboBox
轉換項目使用一種方法來標記
<ComboBox x:Name="SearchGendersComboBox" Grid.Row="3" Grid.Column="1"
IsEditable="True"
SelectedValuePath="Key"
DisplayMemberPath="Value"
SelectedValue="{Binding Path=GenderId}"
/>
,我這個填充它採購組合框:
public void BindComboBoxes()
{
SearchGendersComboBox.ItemsSource = new BindingSource(GenderMgr.GetGendersDropDown(true), null);
SearchGendersComboBox.SelectedIndex = 0;
}
這是GenderMgr
:
public class GenderMgr
{
public static Dictionary<byte, string> GetGendersDropDown(bool isFilterMode = false)
{
return GenderDb.RetrieveGendersDropDown(isFilterMode);
}
}
如何使用我的GenderMgr.GetGendersDropDown
填寫ComboBox
m arkup?
您不會在WPF應用程序中使用'System.Windows.Forms.BindingSource'。從這裏開始閱讀:[數據綁定概述](https://msdn.microsoft.com/en-us/library/ms752347.aspx),特別是*綁定到集合*章節。 – Clemens