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

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

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

    這是一篇懶文:)
    只因在大名鼎鼎的stackoverflow上遇到了牛逼哄哄的 Chris Anderson
    下面我們來(lái)看看牛人是怎樣火眼金睛識(shí)破這三個(gè)神秘家伙的:
    以下內(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 閱讀(2792) 評(píng)論(0)  編輯  收藏 所屬分類: WPF
    主站蜘蛛池模板: 色婷五月综激情亚洲综合| 国产精品一区二区三区免费 | 59pao成国产成视频永久免费 | 巨胸喷奶水视频www免费视频| 少妇中文字幕乱码亚洲影视 | 亚洲三区在线观看无套内射| 精品国产无限资源免费观看| 全黄A免费一级毛片| 亚洲精品视频在线观看视频| www.亚洲色图| 久九九精品免费视频| 国产精品永久免费视频| 97se亚洲国产综合自在线| 亚洲精品无码成人片久久| 免费观看男人免费桶女人视频| 免费看成人AA片无码视频吃奶| 亚洲国产精品无码久久九九大片| 无码欧精品亚洲日韩一区| 免费观看日本污污ww网站一区| 亚洲免费福利视频| 国产区在线免费观看| 亚洲乱码av中文一区二区| 亚洲综合无码一区二区| 亚洲熟伦熟女新五十路熟妇 | 成人毛片免费观看视频在线| 免费高清国产视频| 一级一片免费视频播放| 亚洲国产精品无码久久九九大片 | 男人的天堂网免费网站| 成年网站免费入口在线观看| 亚洲精品无码久久久久秋霞| 亚洲美女免费视频| 久久精品国产亚洲AV麻豆王友容 | 在线亚洲精品视频| 亚洲国产熟亚洲女视频| 久久精品国产亚洲av麻豆色欲| 国产亚洲福利精品一区| 亚洲精品国产高清嫩草影院| 国产一级大片免费看| 日本免费电影一区| 全免费a级毛片免费看不卡|