嗨,我有这个组合框:
<ComboBox x:Name="Orders" Width="150" Grid.Row="0"
HorizontalAlignment="Left"
SelectedItem="{Binding Order}" Margin="3" />
这是viewmodel中的代码:
class MyFerViewModel : Screen, IMyFerViewModel
{
private string[] orders = { "ABC", "CDC", "EFR", "ACER" };
private string order = "ABC";
public string[] Orders { get { return orders; } }
public string Order
{
get { return order; }
set
{
if (value != order)
{
order = value;
Reorder();
}
}
}
[..]
为什么当我看不到视图并在引导程序中出现此错误时?
“无法找到合同ABC的任何实例。”
答案 0 :(得分:1)
您需要将ItemsSource
绑定到组合框并进一步SelectedItem
<ComboBox x:Name="Orders"
Width="150" Grid.Row="0"
HorizontalAlignment="Left"
ItemsSource="{Binding Orders}"
SelectedItem="{Binding Order}"
Margin="3" />
希望有所帮助......