我是WPF编程的新手,而不是C#编码的专业人士.
所以我有以下问题:我有很多不同的组合框和文本框.我想将它们绑定到后台的变量,因为我想用数据库中的数据填充组合框.
所以我在文件
liste.xaml.cs中创建了以下内容:
private Dictionary<string, Filter> _ctrlFilter;
public Dictionary<string, Filter> ctrlFilter {
get { return _ctrlFilter; }
set { _ctrlFilter = value; }
}
Run Code Online (Sandbox Code Playgroud)
当我加载liste.xaml时,它使用以下代码初始化ctrlFilter Dictionary:
ctrlFilter = new Dictionary<string, Filter>
{
//ComboBox
{"hersteller", new Filter("Hersteller", typeof(ComboBox)) },
{"fahrzeugart", new Filter("Fahrzeugart", typeof(ComboBox), false) },
//TextBox
{"baujahr", new Filter("Baujahr", typeof(TextBox), true, typeof(short)) },
{"anschaffungswert", new Filter("Anschaffungswert", typeof(TextBox), true, typeof(decimal)) },
{"finanz_restwert", new Filter("Restwert", typeof(TextBox), true, typeof(decimal)) },
//Others
{"zugelassen", new Filter("Zugelassen", typeof(DatePicker), true, typeof(DateTime)) }, …Run Code Online (Sandbox Code Playgroud)