ComboBox TextWrap绑定 [英] ComboBox TextWrap Binding
本文介绍了ComboBox TextWrap绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下ComboBox
I have the following ComboBox
<ComboBox x:Name="TaskText" Text="{Binding TaskNameBinding}" ItemsSource="{Binding
taskList, ElementName=MainWin}" SelectedValuePath="_id" DisplayMemberPath="_name"
Background="Yellow" Padding="0" Margin="0" BorderThickness="0" Width="90"/>
我想对此组合框应用文本换行,并遵循从答案在这里
I wish to apply Text Wrapping to this combobox and followed to code snippet from the answer here
<ComboBox x:Name="TaskText" ItemsSource="{Binding taskList, ElementName=MainWin}"
SelectedValuePath="_id" DisplayMemberPath="_name" Background="Yellow" Padding="0"
Margin="0" BorderThickness="0" Width="90">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding TaskNameBinding}"
TextTrimming="CharacterEllipsis" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
但是这个模板打破了绑定,组合框没有显示任何值。
But this template is breaking the binding and the combobox displays no values. Any help would be appreciated
推荐答案
查看
<ComboBox x:Name="TaskText" Text="{Binding TaskNameBinding}" ItemsSource="{Binding taskList, ElementName=MainWin}" SelectedValuePath="_id" DisplayMemberPath="_name" Background="Yellow" Padding="0" Margin="0" BorderThickness="0" Width="90">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding _name}"
TextWrapping="Wrap" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
这篇关于ComboBox TextWrap绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文