我正在尝试将 a 数据绑定ComboBox
到strings
. 到目前为止,我得到了以下内容:
在我看来,我有:
<ComboBox Height="23"
HorizontalAlignment="Left"
Margin="133,180,0,0"
Name="comboBox1"
ItemsSource="{Binding Hours}"
VerticalAlignment="Top"
Width="38" />
在我的 ViewModel 中,我有:
private List<string> tripTimeHours = new List<string>();
private List<string> tripTimeMinutes = new List<string>();
public CreateTripViewModel()
{
TripName = new DataWrapper<string>(this, tripNameChangeArgs);
TripName.IsEditable = true;
setObjects();
CreateTripFiredCommand = new SimpleCommand<object, EventToCommandArgs>(ExecuteCreateTripCommand);
}
private void setObjects()
{
for (int i = 0; i < 24; i++)
{
tripTimeHours.Add(i.ToString());
}
for (int i = 0; i < 60; i++)
{
tripTimeMinutes.Add(i.ToString());
}
}
public List<string> Hours
{
get
{
return tripTimeHours;
}
}
public List<string> Minutes
{
get
{
return tripTimeMinutes;
}
}
我想要做的是从这些组合框中返回选定的项目。我想我快到了,但只需要完成最后一步。