0
嗨,我有一個組合框控件在我的頁面組合框的數據是從視圖模型使用IEnumerable集合生成的。現在我想在組合框項目的最後添加一個靜態字符串。這個怎麼做?我重視我的組合框的截屏,擁有4個值,現在我想添加一個字符串例如如何在Silverlight中將靜態字符串值添加到組合框?
「自定義大小」在項目的底部。我也附加了我的視圖模型代碼。
PartsDomainContext context;
private IEnumerable<CategoryHierarchy> Categoryhierarchies;
private IEnumerable<CategoryHierarchy> _SizeCategoryhierarchies;
private CategoryHierarchy categoryhierarchy;
private CategoryHierarchy _Sizecategoryhierarchy;
private ProductCategory productcategory;
public IEnumerable<CategoryHierarchy> SizeCategoryHierarchies
{
get
{
return _SizeCategoryhierarchies;
}
set
{
_SizeCategoryhierarchies = value;
}
}
public CategoryHierarchy SizeCategoryHierarchy
{
get { return _Sizecategoryhierarchy; }
set
{
if (_Sizecategoryhierarchy == null)
{
_Sizecategoryhierarchy = value;
OnPropertyChanged("SizeCategoryHierarchy");
ActiveData.Instance.size = _Sizecategoryhierarchy.Category.CategoryName.ToString();
ActiveData.Instance.Description1 = _Sizecategoryhierarchy.Category.Description1;
ActiveData.Instance.Description2 = _Sizecategoryhierarchy.Category.Description2;
ActiveData.Instance.ShortDescription1 = _Sizecategoryhierarchy.Category.ShortDescription1;
ActiveData.Instance.Notes = _Sizecategoryhierarchy.Category.Notes;
}
else
{
try
{
_Sizecategoryhierarchy = value;
OnPropertyChanged("SizeCategoryHierarchy");
ActiveData.Instance.size = _Sizecategoryhierarchy.Category.ToString();
}
catch (Exception ex)
{
}
finally
{
}
}
}
}
public Wizard1ViewModel()
{
GetSize();
}
public void GetSize(int parentcategory)
{
context = new PartsDomainContext();
IsBusy = true;
context.Load(context.GetCategoryByHierarchyQuery(1), e =>
{
if (!e.HasError)
{
SizeCategoryHierarchies = e.Entities.Where(c => c.ParentCategory.Equals(parentcategory));
OnPropertyChanged("SizeCategoryHierarchies");
IsBusy = false;
}
}, null);
}
//Xaml
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="0*" />
<RowDefinition Height="300*" />
</Grid.RowDefinitions>
<ComboBox Name="poolsize" ItemsSource="{Binding SizeCategoryHierarchies, Mode=TwoWay}" DisplayMemberPath="Category.CategoryName" SelectedValuePath="Category.CategoryName" SelectedItem="{Binding SizeCategoryHierarchy, Mode=TwoWay}" HorizontalAlignment="Left" Margin="132,0,0,82" FontSize="16" VerticalAlignment="Bottom" Width="216" RenderTransformOrigin="0.505,2.967" DropDownOpened="poolsize_DropDownOpened_1"/>
</Grid>