このコードにより、「引数が範囲外」という例外が発生します。へのバインディングを削除すると、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>