Silverlight 4中的AutococteTebox绑定到字典 - 仅显示值问题
-
28-09-2019 - |
题
我已经使用了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>
不隶属于 StackOverflow