2010-02-26 46 views
0

在我的Silverlight页面中,我有一个组合框。在代码隐藏我填充组合框的项目,像这样:Silverlight组合框的辅助功能项目

this.ProblemList.Items.Add(Strings.Review_SelectProblem); 
this.ProblemList.Items.Add(Strings.Review_IncorrectCharacters); 
this.ProblemList.Items.Add(Strings.Review_MissingText); 
... 
this.ProblemList.SelectedIndex = 0; //Set the default selection 

其他地方,在我的XAML页面,我通过这样的可访问(残疾人)其它非组合框控件:

AutomationProperties.Name="{Binding Strings.Review_Access_ParagraphCorrect}" 

我想提供辅助我的组合框的项目,但我已经能够找到的唯一的办法就是像这样:

AutomationProperties.SetLabeledBy(this.nameInput, this.nameLabel); 

这样做的问题是,我的组合框的项目必须有一个名字。如何以编程方式为我的组合框项目指定名称,或者如何在代码后面提供辅助功能以及引用组合框项目的名称时的可访问性?

感谢你的帮助,

亚伦

回答

1

你可以尝试使用这样的:

ComboBoxItem tmpItem = new ComboBoxItem(); 
tmpItem.Content = Strings.Review_SelectProblem; 
tmpItem.Name = Strings.Review_SelectProblem; 
this.ProblemList.Items.Add(tmpItem); 

我希望我理解正确你。