我已经使用了AutococteTebox USERCONTROL。我有一个类型的字典 Dictionary<int,string> 其中包含ID和名称。我想在AutococteTebox中仅显示名称。我可以做到

autoCompleteBox1.ItemsSource = dict.Values;

My problem is whenever any name is selected I want to retrieve the id associated with it.但是我不想向用户显示ID,因为这些ID是出于内部目的。我该怎么做?提前致谢。

有帮助吗?

解决方案

我使用了以下内容:

<AutoCompleteBox ItemsSource="{Binding MyDict}" ValueMemberPath="Value">
   <AutoCompleteBox.ItemTemplate>
      <DataTemplate>
         <TextBlock Text={Binding Value}/>
      </DataTemplate>
   </AutoCompleteBox.ItemTemplate>
</AutoCompleteBox>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top