目前我正在尝试填充ObservableCollection,但收到此错误
is not of type "System.Int32" and cannot be used in this generic collection
自动填充框中填充了数字,当我尝试从列表中选择一个项目时,会产生错误。
我可以向我出错的地方索取一些指导。
public ObservableCollection<int> number = new ObservableCollection<int>();
public ObservableCollection<int> Number
{
get { return value; }
set
{
number = value;
RaisePropertyChanged("Number");
}
}
public ObservableCollection<PaymentInfo> Payments
{ get; set; }
xaml方:
<telerik:RadAutoCompleteBox
SelectedItems="{Binding Number, Mode=TwoWay}"
SelectionMode="Multiple"
ItemsSource="{Binding Payments}"
DisplayMemberPath="PaymentNo"
TextSearchPath="PaymentNo" />
答案 0 :(得分:0)
将定义以下属性
public ObservableCollection<PaymentInfo> SelectedPayments
{
get { return value; }
set
{
number = value;
RaisePropertyChanged("SelectedPayments");
}
}
将其绑定到SelectedItems="{Binding SelectedPayments, Mode=TwoWay}"