WPF ComboBox长文本显示问题

时间:2016-11-17 19:53:19

标签: wpf data-binding combobox

我有一个绑定到数据表的组合框。它有很多记录,长文本。

我已将显示成员路径设置为显示所有文本但显然会占用大量屏幕空间。因此,当用户点击下拉列表时,我想显示完整的显示成员路径,但在选择时我想显示前10个字符?如图所示。

我有什么方法可以做到这一点吗?

enter image description here

                            <ComboBox Name="Texas_AON" IsEditable="True"
                      Grid.Row="0" Grid.Column="1" Visibility="{Binding Source='TX_ASL', Converter={local:NistRuleToVisibilityConverter}, ConverterParameter='97'}"
                      ItemsSource="{Binding Data.Tables[TxOffenseCodes]}"
                      SelectedValuePath="Code"
                      DisplayMemberPath="Description"
                                  VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" 
                          VirtualizingStackPanel.IsContainerVirtualizable="True" VirtualizingStackPanel.IsVirtualizingWhenGrouping="True"
                      Style="{DynamicResource PerformanceComboBox}" Margin="2" FontSize="12"  >
                            <ComboBox.SelectedValue>
                                <Binding Path="NF.t2.Texas412.Offenses[0].AON" Mode="TwoWay" ValidatesOnDataErrors="True" UpdateSourceTrigger="PropertyChanged" NotifyOnValidationError="True" ValidatesOnExceptions="True" >
                                    <Binding.ValidationRules>
                                        <local:FieldValidator ValidatesOnTargetUpdated="True" FieldName="AON" FieldNum="97"/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </ComboBox.SelectedValue>
                            <ComboBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel />
                                </ItemsPanelTemplate>
                            </ComboBox.ItemsPanel>
                        </ComboBox>

0 个答案:

没有答案