There is a little gotcha here when you overwrite the itemcontainerstyle on an items control. If you want to allow quick access items by typing prefixes of strings you need to setup some attached properties.
There is 2 ways you can go you can either add the TextSearch.TextPath attached property on the ItemControl or add the TextSearch.Text attached property on the individual item.
Example:
<ComboBox IsEditable="true" TextSearch.TextPath="Name">
<Image Name="Cat" Source="data\cat.png"/>
<Image Name="Dog" Source="data\dog.png"/>
<Image Name="Fish" Source="data\fish.png"/>
ComboBox>
<ComboBox IsEditable="true">
<Image TextSearch.Text="Cat" Source="data\cat.png"/>
<Image TextSearch.Text="Dog" Source="data\dog.png"/>
<Image TextSearch.Text="Fish" Source="data\fish.png"/>
ComboBox>
Example of how to do this when overwriting the itemcontainerstyle:
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="TextSearch.Text">
<Setter.Value>
<MultiBinding StringFormat="{} {0} {1}">
<Binding Path="FirstName"/>
<Binding Path="LastName"/>
MultiBinding>
Setter.Value>
Setter>
Style>
ComboBox.ItemContainerStyle>
MSDN Documentation http://msdn.microsoft.com/en-us/library/ms617617(v=VS.100).aspx
No comments:
Post a Comment