C# 在组合框中添加默认项

C# 在组合框中添加默认项,c#,silverlight,combobox,C#,Silverlight,Combobox,绑定后,我想在组合框的第0个索引处添加一个默认项。我试着这样做: cboProductType.ItemsSource = e.Result; cboProductType.Items.Insert(0, "--Select Products--"); //error on this line 但有一个错误: 只读集合上不支持操作 在Silverlight组合框中添加默认项的方法是什么?但是 我假设您使用的是WPF和XAML,请尝试以下方法: 源代码:local:ExtendedCombo

绑定后,我想在
组合框的
第0个索引处添加一个默认项。我试着这样做:

cboProductType.ItemsSource = e.Result;
cboProductType.Items.Insert(0, "--Select Products--");  //error on this line
但有一个错误:

只读集合上不支持操作

在Silverlight组合框中添加默认项的方法是什么?

但是

我假设您使用的是WPF和XAML,请尝试以下方法:

源代码:
local:ExtendedComboBox
位于:

altentive

是使用文本创建默认的
ProductType
“--选择产品--”
,然后添加到集合oj位置0

e.Result.Add(new ProductType { Text =" --Select Products-- " });

cboProductType.ItemsSource = e.Result;

类似的东西。

Result.Add
不需要两个参数sok,e.Result的类型是什么?
observateCollection
ProductType
是我的类组合框不包含
文本的定义。不,在我假设您使用WinForms之前,我正在使用Silverlight,对不起。我更新我的答案
<local:ExtendedComboBox ItemsSource="{Binding ...Whatever...}" NotSelectedText="--Select Products--" />
e.Result.Add(new ProductType { Text =" --Select Products-- " });

cboProductType.ItemsSource = e.Result;