I've spent about a day searching for this with no luck. I just expected this to work but while the combobox shows the text content wordwrapped when the dropdown list is not showing, the individual items in the dropdownlist are not wordwrapped. I can still change the style for all the line items, but the text does not wrap. I've played with all sorts of variations of ItemsPanelTemplate to no avail.
My existing item template is trivial.
<ComboBox.ItemTemplate>
<DataTemplate DataType="entities:Client">
<StackPanel>
<TextBlock Background="LightCoral" Text="{Binding Description}" TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
Help! Thanks
From the comments on the question:
StackPanel
allows infinite layout space. You need to set a MaxWidth
or other similar constraint on your TextBlock
. If you want the width of your ComboBox
, you can use the following:
MaxWidth="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=ComboBox},
Path=ActualWidth}"