日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

转载:ListBox的SelectedValue和SelectedItem的区别

發(fā)布時間:2024/7/19 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 转载:ListBox的SelectedValue和SelectedItem的区别 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
轉(zhuǎn)載:ListBox的SelectedValue和SelectedItem的區(qū)別 原文:http://www.beacosta.com/blog/?p=9

What is the difference between SelectedValue and SelectedItem?

When they are used by themselves, these two properties are very similar. The need for both and the difference between the two becomes apparent when SelectedValuePath is also set.

For example, consider our well-known GreekGods data source. I set the DataContext of the StackPanel to be that collection through code:

????GreekGods items;
????items = new GreekGods();
????mainStackPanel.DataContext = items;

And used an empty Binding to bind that collection to the ListBox. I know that I want to select the GreekGod with description “Messenger of the Gods” (even though I am only displaying the Name of each God). This is when SelectedValuePath becomes useful. Each item in the ListBox is a GreekGod object, so by setting SelectedValuePath to “Description” I am able to drill down into the Description property of each GreekGod. Then I just have to set SelectedValue to the description I am looking for and the item becomes selected.

????<StackPanel Name=”mainStackPanel”>
????????<ListBox ItemsSource=”{Binding}” DisplayMemberPath=”Name” SelectedValue=”Messenger of the Gods” SelectedValuePath=”Description” Name=”listBox1″ (…) />
????</StackPanel>

// 注意這里可以用一個空的綁定,選擇了GreekGod的Name作為DisplayMember,選擇Description作為SelectedValue的選擇字段,并且這里選擇了Description的內(nèi)容是"Messenger of the Gods"的那個Item。

The difference between SelectedValue and SelectedItem should be obvious now. SelectedValue returns the string it was set to (”Messenger of the Gods”), while SelectedItem returns the actual GreekGod object with that description.

????string messengerOfGods = (string)(listBox1.SelectedValue);
????GreekGod hermes = (GreekGod)(listBox1.SelectedItem);

SelectedValue is particularly useful when only part of your item is stored in the model you are data binding to. In this scenario, you would data bind the SelectedValue property to the partial information in your model but the ListBox can show a lot more information about that item.

If you have ideas of how to combine these two properties in one, we would love to hear it.

Here you can find the VS project with this sample code. Put a breakpoint in the handler for the button click to inspect the values of SelectedValue and SelectedItem when the button is clicked. This works with September CTP WPF bits.

posted on 2008-10-20 15:52 cutebear 閱讀(...) 評論(...) 編輯 收藏

轉(zhuǎn)載于:https://www.cnblogs.com/bear831204/archive/2008/10/20/1313538.html

總結(jié)

以上是生活随笔為你收集整理的转载:ListBox的SelectedValue和SelectedItem的区别的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日韩欧美三级在线观看 | 丁香花完整视频在线观看 | 激情小说一区 | 中文字幕无线码一区 | 国产内射合集颜射 | 人人射人人干 | 99久久久无码国产精品免费蜜柚 | 中文字幕人成人乱码亚洲电影 | 中文在线天堂网 | 一区二区三区欧美在线 | 亚洲欧美日本一区 | 日韩精品免费播放 | 日本黄区免费视频观看 | 丰满少妇在线观看网站 | 欧美日韩视频在线 | 精品国产影院 | 中文字幕日韩高清 | 欧美日韩视频在线播放 | 国产白丝一区二区三区 | 无码乱人伦一区二区亚洲 | 婷婷五月在线视频 | 精品少妇白浆小泬60P | 成人黄色性视频 | 黄色三级网站在线观看 | 天天射天天干天天操 | 男女涩涩视频 | 国产伦精品一区二区三区在线观看 | 国精产品一区一区三区免费视频 | 超碰天天干| 国产成人精品一区二区三区网站观看 | 91porn破解版 | 亚洲男人精品 | 日韩精品在线免费观看 | 亚洲2022国产成人精品无码区 | 请用你的手指扰乱我吧 | 爱爱视频网 | 欧美videos另类精品 | 日韩福利视频一区 | 九九在线视频 | 叶爱在线 | 中文国产在线观看 | 亚洲一区日韩精品 | 天天色成人网 | 久久一区二区三区四区五区 | 日韩色 | 久久久久成人片免费观看蜜芽 | h片在线播放 | 中文字幕亚洲一区二区三区 | 神马久久精品 | 人人玩人人干 | 中文无码日韩欧 | 免费黄色网址视频 | 亚洲人成小说 | 韩国三级国产 | 成人免费va视频 | 深夜福利一区二区三区 | 亚洲免费三区 | 成人动漫免费观看 | 国产污污在线观看 | 穿扒开跪着折磨屁股视频 | 久草久草| 免费又黄又爽又色的视频 | 国产一区二区激情 | 国产亚洲av片在线观看18女人 | 久久婷婷精品 | 自拍中文字幕 | 超碰碰碰碰 | 色综合久久久久久 | 午夜时刻免费入口 | 在线欧美| 国产成人自拍视频在线 | 黄页网站在线看 | 亚洲精品一二 | 成人在线免费看片 | 欧美性潮喷xxxxx免费视频看 | 成人性生交大片免费看 | 亚洲欧美在线视频免费 | 久久人成 | 黄色大全免费观看 | 国内外成人在线视频 | 日本人xxxⅹ18hd19hd | 国产日韩精品在线观看 | 国产第一草草影院 | 99热99| 亚洲97视频 | 亚洲情趣| 亚洲永久在线 | 最新视频 - 88av | www.色人阁.com | 一出一进一爽一粗一大视频 | 国产后入又长又硬 | 欧美少妇18p | 第一页在线 | 亚洲欧美一区二区三区 | 久久婷婷综合色丁香五月 | 日韩一级片网站 | 国产15页 | 国产91精 | 中文字幕日韩欧美 |