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

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

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

    這是一篇懶文:)
    只因在大名鼎鼎的stackoverflow上遇到了牛逼哄哄的 Chris Anderson
    下面我們來看看牛人是怎樣火眼金睛識破這三個神秘家伙的:
    以下內容完全轉自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 閱讀(2812) 評論(0)  編輯  收藏 所屬分類: WPF
    主站蜘蛛池模板: 欧美最猛性xxxxx免费| 免费少妇a级毛片| 久久精品国产亚洲av成人| 中文字幕成人免费高清在线视频| 亚欧日韩毛片在线看免费网站| 女人18毛片水真多免费看| 亚洲人和日本人jizz| 噼里啪啦电影在线观看免费高清 | 精品免费AV一区二区三区| 中文字幕无线码中文字幕免费| 亚洲AV无码乱码在线观看性色扶| 久久精品国产亚洲av麻豆 | 最近2019免费中文字幕视频三| 亚洲?V无码乱码国产精品| 男人免费视频一区二区在线观看| 无码专区永久免费AV网站| 国产亚洲精品成人AA片| 男人的天堂网免费网站| 亚洲精品福利在线观看| 成年女人免费碰碰视频| 国产亚洲福利一区二区免费看| 国产日韩成人亚洲丁香婷婷| 亚洲中文无码永久免| h视频在线免费看| 亚洲狠狠色丁香婷婷综合| 亚洲AⅤ无码一区二区三区在线| 国产福利在线观看永久免费| 亚洲va在线va天堂va888www| 久久精品免费全国观看国产| 亚洲视频在线观看免费| 国产精品69白浆在线观看免费| 色天使亚洲综合一区二区| 日韩高清在线高清免费| 国产V片在线播放免费无码 | 国产精品无码一区二区三区免费 | 亚洲欧洲精品成人久久曰| 亚洲女同成人AⅤ人片在线观看| 国产成人高清亚洲一区91| 亚洲国产精品无码中文字| 黄页免费的网站勿入免费直接进入| 青草青草视频2免费观看|