Reputation: 547
I have a combobox with Textboxes as Items i like to set the width of Textboxes to the width of Combobox. So at moment the Textbox expand with the size of text but it should wrap when width is the same as the combobox... this is my xaml:
<ComboBox
Margin="51,146,238,146"
BorderThickness="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Padding="3" Height="20" IsEditable="True"
x:Name="testCombobox" SelectionChanged="testCombobox_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBox
TextWrapping="Wrap"
AcceptsReturn="True"
Padding="1,1,1,1"
Background="Yellow">
</TextBox>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Upvotes: 1
Views: 1408
Reputation: 9249
Try to add the following to stretch the TextBoxes inside the ComboBoxItems:
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter
Property="HorizontalContentAlignment"
Value="Stretch"/>
</Style>
</ComboBox.ItemContainerStyle>
Upvotes: 3