Я связываю ExpMonth и ExpYear с выпадающим списком HTML. Я добавил значения жестко закодированы. Но нужно уменьшить количество кода.
* HTML КОД *
<input data-tabbable="1" data-role="dropdownlist" data-placeholder="Exp. Month" data-text-field="ExpMonthTitle" data-value-field="ExpMonthId" data-bind="source:ExpMonthList, value:Model.SelectExpMonthId"/>
* КОД ПРОСМОТРА МОДЕЛИ *
private void InitializeList()
{
ExpMonthList = new ObservableCollection<SelectExpMonth>
{
new SelectExpMonth() { ExpMonthId = 0, ExpMonthTitle = "Exp.Month" },
new SelectExpMonth() { ExpMonthId = 1, ExpMonthTitle = "1" },
new SelectExpMonth() { ExpMonthId = 2, ExpMonthTitle = "2" },
new SelectExpMonth() { ExpMonthId = 3, ExpMonthTitle = "3" },
new SelectExpMonth() { ExpMonthId = 4, ExpMonthTitle = "4" },
new SelectExpMonth() { ExpMonthId = 5, ExpMonthTitle = "5" },
new SelectExpMonth() { ExpMonthId = 6, ExpMonthTitle = "6" },
new SelectExpMonth() { ExpMonthId = 7, ExpMonthTitle = "7" },
new SelectExpMonth() { ExpMonthId = 8, ExpMonthTitle = "8" },
new SelectExpMonth() { ExpMonthId = 9, ExpMonthTitle = "9" },
new SelectExpMonth() { ExpMonthId = 10, ExpMonthTitle = "10" },
new SelectExpMonth() { ExpMonthId = 11, ExpMonthTitle = "11" },
new SelectExpMonth() { ExpMonthId = 12, ExpMonthTitle = "12" },
};
Model.SelectExpMonthId = 0;
int currentYear = DateTime.Now.Year;
ExpYearList = new ObservableCollection<SelectExpYear>
{
new SelectExpYear(){ExpYearId=0, ExpYearTitle="Exp.Year"},
new SelectExpYear(){ExpYearId=1, ExpYearTitle=(currentYear).ToString()},
new SelectExpYear(){ExpYearId=2, ExpYearTitle=(currentYear+1).ToString()},
new SelectExpYear(){ExpYearId=3, ExpYearTitle=(currentYear+2).ToString()},
new SelectExpYear(){ExpYearId=4, ExpYearTitle=(currentYear+3).ToString()},
new SelectExpYear(){ExpYearId=5, ExpYearTitle=(currentYear+4).ToString()},
new SelectExpYear(){ExpYearId=6, ExpYearTitle=(currentYear+5).ToString()},
new SelectExpYear(){ExpYearId=7, ExpYearTitle=(currentYear+6).ToString()},
//new SelectExpYear(){ExpYearId=0, ExpYearTitle="Exp.Year"}
//new SelectExpYear(){ExpYearId=0, ExpYearTitle="Exp.Year"},
//new SelectExpYear(){ExpYearId=0, ExpYearTitle="Exp.Year"},
//new SelectExpYear(){ExpYearId=0, ExpYearTitle="Exp.Year"},
};
Model.SelectExpYearId = 0;