我在Silverlight中使用RadComboBox。我从某处获得了绑定数据。问题是当我单击下拉箭头关闭菜单但选择的文本没有聚焦或突出显示时。
此RadComboBox有LostFocus
,DropDownOpened
和SelectionChanged
个事件。我把代码
System.Windows.Browser.HtmlPage.Plugin.Focus();
this.comboBox.Focus();
在这些事件中的任何一个。
但下拉菜单中的所选文字无法聚焦(高亮显示)。也许它不能在自己的事件中实现?
修改
代码:
<RadComboBox
Grid.Column="2"
Grid.Row="12"
x:Name="fileLocDropDown"
LostFocus="FileLocDropDown_LostFocus"
KeyDown="FileLocDropDown_KeyDown"
DropDownOpened="FileLocationDropDown_DropDownOpened"
IsEditable="True"
CanAutocompleteSelectItems="True"
IsUpperCase="True"
MaxDropDownHeight="600"
IsTextSearchEnabled="True"
Text="{Binding FileLocCode,Mode=TwoWay, Converter={StaticResource NullValueConverter},ConverterParameter='Text',NotifyOnValidationError=True}"
MaxLength="3"
SelectionChanged="FileLocDropDown_SelectionChanged"
ItemsSource="{Binding FileLocList}">
<RadComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Background="LightYellow" >
<TextBlock Margin="4,0,4,0" HorizontalAlignment="Left" Text="{Binding FileLocCode}" Width="30" />
<TextBlock Margin="4,0,4,0" HorizontalAlignment="Left" Text="{Binding FileLocName}" Width="150" />
</StackPanel>
</DataTemplate>
</RadComboBox.ItemTemplate>
图像:
答案 0 :(得分:0)
在RadComboBox上设置以下值:
CanAutocompleteSelectItems="True" IsEditable="True"
这可以为您提供所需的行为,但它确实意味着用户可以在输入字段中输入任何随机文本,因此您可能需要处理此问题。
编辑: 在FileLocList包含的类中创建一个新属性,它连接FileLocCode和FileLocName字符串(在那里有一个换行符,我想如果你想复制stackpanel的效果)。
然后,摆脱ItemTemplate并将DisplayMemberPath连接到新字符串。