这段代码给了我一个“参数超出范围”异常。当我删除对 的绑定时SelectedIndex
,ComboBox
填充得很好并且没有抛出异常。
知道我做错了什么吗?这(出于某种原因)不可能吗?
代码:
public class RuleMap<T> : INotifyPropertyChanged
{
public ObservableCollection<string> Options
{
get
{
return new ObservableCollection(){"A", "B", "C"};
}
}
public int SelectedIndex
{
get
{
return 0;
}
}
}
public ObservableCollection<RuleMap> FilterItemSource;
XAML:
<ItemsControl ItemsSource="{Binding FilterItemSource}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal"> <ComboBox Width="150" SelectedIndex="{Binding SelectedIndex}"
ItemsSource="{Binding Options}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>