<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    這是一篇懶文:)
    只因在大名鼎鼎的stackoverflow上遇到了牛逼哄哄的 Chris Anderson
    下面我們來看看牛人是怎樣火眼金睛識破這三個神秘家伙的:
    以下內(nèi)容完全轉(zhuǎn)自stackoverflow

    Their names can be a bit confusing :). Here's a summary:

    • The SelectedItem property returns the entire object that your list is bound to. So say you've bound a list to a collection of Category objects (with each Category object having Name and ID properties). eg. ObservableCollection<Category>. The SelectedItem property will return you the currently selected Category object. For binding purposes however, this is not always what you want, as this only enables you to bind an entire Category object to the property that the list is bound to, not the value of a single property on that Category object (such as its ID property).

    • Therefore we have the SelectedValuePath property and the SelectedValue property as an alternative means of binding (you use them in conjunction with one another). Let's say you have aProduct object, that your view is bound to (with properties for things like ProductName, Weight, etc). Let's also say you have a CategoryID property on that Product object, and you want the user to be able to select a category for the product from a list of categories. You need the ID property of the Category object to be assigned to the CategoryID property on the Product object. This is where the SelectedValuePath and the SelectedValue properties come in. You specify that the ID property on the Category object should be assigned to the property on the Product object that the list is bound to using SelectedValuePath='ID', and then bind the SelectedValueproperty to the property on the DataContext (ie. the Product).

    The example below demonstrates this. We have a ComboBox bound to a list of Categories (via ItemsSource). We're binding the CategoryID property on the Product as the selected value (using the SelectedValue property). We're relating this to the Category's ID property via the SelectedValuePath property. And we're saying only display the Name property in the ComboBox, with the DisplayMemberPath property).

    <ComboBox ItemsSource="{Binding Categories}" 
              SelectedValue
    ="{Binding CategoryID, Mode=TwoWay}" 
              SelectedValuePath
    ="ID" 
              DisplayMemberPath
    ="Name" />

    It's a little confusing initially, but hopefully this makes it a bit clearer... :)

    Chris

















    posted on 2015-06-11 10:55 Ying-er 閱讀(2811) 評論(0)  編輯  收藏 所屬分類: WPF
    主站蜘蛛池模板: 久久亚洲精品无码VA大香大香| 亚洲精品成人片在线观看精品字幕| 亚洲性无码av在线| 99久久99久久精品免费观看| 亚洲大片在线观看| 99re6免费视频| 亚洲综合激情视频| 五月天婷亚洲天综合网精品偷| 亚洲色一区二区三区四区| 妞干网免费观看视频| 国产精品亚洲玖玖玖在线观看| 理论秋霞在线看免费| 国产福利电影一区二区三区,亚洲国模精品一区 | 免费观看大片毛片| 亚洲av成人中文无码专区| 日韩精品视频免费观看| 国产精品亚洲五月天高清| 亚洲精品无码成人片在线观看| 亚洲免费日韩无码系列| 亚洲av中文无码乱人伦在线播放 | 国产精品免费一级在线观看| 国产亚洲精品免费| 中文字幕亚洲乱码熟女一区二区| 亚洲成a人片在线网站| 无码少妇一区二区浪潮免费| 亚洲国产精品18久久久久久| 亚洲va中文字幕无码| 色www永久免费网站| 国产jizzjizz免费视频| 亚洲宅男天堂a在线| 永久免费AV无码网站在线观看| 免费毛片毛片网址| 少妇中文字幕乱码亚洲影视| 免费电视剧在线观看| 一级毛片完整版免费播放一区| 亚洲成a人片在线观看日本| 18禁无遮挡无码网站免费| 亚洲黄片手机免费观看| 亚洲老熟女@TubeumTV| 亚洲A丁香五香天堂网| 免费黄色福利视频|