我正在使用Tim Heuer的风格从这里获得一个可编辑的组合框:
http://timheuer.com/blog/archive/2008/11/05/silverlight-editable-combobox-using-styles.aspx
http://timheuer.com/blog/archive/2008/11/05/silverlight-editable-combobox-using-styles.aspx
这在我的项目中运行良好,大约是Silverlight Toolkit的早期版本.不幸的是,尝试将此样式与SL3 RTM和最新的SL Toolkit一起使用不起作用.我怀疑问题与此有关:“破坏变化:ToggleButton类型的”DropDownToggle“模板部分已被删除.”我不知道如何修复它以使下拉部分再次工作,任何想法?
解决方法
对我来说现在有效.我在EditableComboStyle模板中将此行添加到ToggleButton声明中:
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsDropDownOpen,Mode=TwoWay}"
同样重要的是将ListBox名称更改为x:Name =“Selector”在同一个EditableComboStyle模板中,如Jeff所说.然后控件用作:
<toolkit:AutoCompleteBox MinimumPrefixLength="0" MinimumPopulateDelay="200" x:Name="editableCombo" Style="{StaticResource EditableComboStyle}" Text="{Binding MyProperty,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnExceptions=True}" />
但不幸的是,当所需的可编辑组合框行为起作用时,会出现其他问题:
>当用户点击toogle按钮时,我遇到立即绑定问题,导致在选择任何项目或写入文本之前立即进行验证.>用户必须按Tab键两次才能移动到其他控件.