WPF:ComboBox DataTemplate

时间:2011-10-03 18:06:23

标签: wpf wpf-controls wpftoolkit

XAML:

 <dxe:ComboBoxEdit x:Name="UserSelectComboBox" Margin="68.497,31.75,0,48.213" 
  Background=   {DynamicResource TextBoxBackground}" Height="{DynamicResource 
  TextBoxHeight}" FontSize="{DynamicResource TextFontSize}" 
  HorizontalAlignment="Left" Width="149.333" Text="{Binding  
  SelectedItemValue, ElementName=UserSelectComboBox, Mode=OneWay}">
  <dxe:ComboBoxEdit.ItemTemplate>
        <DataTemplate>
    <StackPanel Orientation="Horizontal">
      <Image Source="{Binding UImages, Converter=   {StaticResource 
              byteToImageConverter}}" Width="40" Height="40"/>
      <TextBlock Text="{Binding UId}" Margin="5,0,0,0"/>
    </StackPanel>
    </DataTemplate>
  </dxe:ComboBoxEdit.ItemTemplate>
</dxe:ComboBoxEdit>

我正在使用DevExpress ComboBox。当我选择ComboBox中的任何项目时,其文本显示 Procesta.CvServer.Class.Propertys.UserTeamView ,这是我的绑定源名称。

enter image description here

我想只展示UId。

1 个答案:

答案 0 :(得分:1)

您将Text绑定到SelectedItemValue。请尝试绑定到SelectedItemValue.UId