简体   繁体   English

尝试填充ObservableCollection时出错

[英]Error when trying to populate ObservableCollection

Currently I'm trying to populate ObservableCollection but getting this error 目前,我正在尝试填充ObservableCollection,但出现此错误
is not of type "System.Int32" and cannot be used in this generic collection The Autocompletebox is populated with numbers, and when I try to select an item from the list the error is produced. is not of type "System.Int32" and cannot be used in this generic collection 。自动完成框用数字填充,当我尝试从列表中选择一个项目时,会产生错误。

May I get some guidances towards where I'm going wrong. 我可以得到一些有关我要去哪里出错的指导。

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 side: xaml面:

<telerik:RadAutoCompleteBox
    SelectedItems="{Binding Number, Mode=TwoWay}" 
    SelectionMode="Multiple"
    ItemsSource="{Binding Payments}"  
    DisplayMemberPath="PaymentNo"      
    TextSearchPath="PaymentNo" />

Would define the following property 将定义以下属性

    public ObservableCollection<PaymentInfo> SelectedPayments
{
    get { return value; }
    set
    {
        number = value;
        RaisePropertyChanged("SelectedPayments");
    }
}

Bind it to SelectedItems="{Binding SelectedPayments, Mode=TwoWay}" 将其绑定到SelectedItems="{Binding SelectedPayments, Mode=TwoWay}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更改为ObservableCollection时出错 - Error when changing to ObservableCollection 尝试填充列表对象时出现致命错误 - Fatal error when trying to populate list object * .StartPageControl.ClioViewModel.Groups&#39;是一个“属性”,但在尝试将元素添加到ObservableCollection时像“类型”错误一样使用<string> - *.StartPageControl.ClioViewModel.Groups' is a 'property' but is used like a 'type' error when trying to add element to ObservableCollection<string> 填充嵌套的ObservableCollection - Populate Nested ObservableCollection 我可以使用LINQ来填充ObservableCollection的ObservableCollection吗 - Can i use LINQ to populate an ObservableCollection of ObservableCollection 如何通过绑定填充ObservableCollection - How to Populate an ObservableCollection through bindings Open XML SDK:尝试填充超过25列时出现“Unreadable content”错误 - Open XML SDK: get “Unreadable content” error when trying to populate more than 25 columns 尝试从数据库填充DropDownListFor时出错 - Error while trying populate DropDownListFor from Database 当我返回ObservableCollection时,为什么会出现此超时错误? - Why am I getting this timeout error when I return an ObservableCollection? 填充ObservableCollection <string> 使用字符串数组 - populate ObservableCollection<string> using string array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM