开发者

AutoCompleteBox in Silverlight 4 bound to dictionary - show only values issue

开发者 https://www.devze.com 2023-01-04 11:12 出处:网络
I have used AutoCompleteBox usercontrol. I have a dictionary of type Dict开发者_开发技巧ionary<int,string> which contains ids and names. I want to show only names in the AutoCompleteBox. I can d

I have used AutoCompleteBox usercontrol. I have a dictionary of type Dict开发者_开发技巧ionary<int,string> which contains ids and names. I want to show only names in the AutoCompleteBox. I can do it with

autoCompleteBox1.ItemsSource = dict.Values;

My problem is whenever any name is selected I want to retrieve the id associated with it. But I don't want to display the ids to the user as those are for internal purpose. How can I do it?


I used following :

<AutoCompleteBox ItemsSource="{Binding MyDict}" ValueMemberPath="Value">
   <AutoCompleteBox.ItemTemplate>
      <DataTemplate>
         <TextBlock Text={Binding Value}/>
      </DataTemplate>
   </AutoCompleteBox.ItemTemplate>
</AutoCompleteBox>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号