<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
    主站蜘蛛池模板: 天天天欲色欲色WWW免费| 中国一级全黄的免费观看| 91av视频免费在线观看| 亚洲国产精品成人精品无码区| 美女尿口扒开图片免费| 四虎影在线永久免费观看| 亚洲gay片在线gv网站| 国产精品久久免费视频| 狠狠入ady亚洲精品| 九月婷婷亚洲综合在线| 日韩精品无码免费视频| 自拍偷自拍亚洲精品被多人伦好爽| 一级看片免费视频| 亚洲线精品一区二区三区影音先锋| 国产午夜不卡AV免费| 亚洲AV无码精品无码麻豆| 久久久久久精品免费看SSS| 亚洲av乱码一区二区三区香蕉 | 男人扒开添女人下部免费视频| 亚洲AV蜜桃永久无码精品| jizz中国免费| 久久亚洲精品无码AV红樱桃| 18禁男女爽爽爽午夜网站免费| 亚洲无线一二三四区| 好爽好紧好大的免费视频国产| 理论片在线观看免费| 久久久久亚洲精品成人网小说 | 亚洲国产综合精品中文第一| 国产成人在线观看免费网站| 插鸡网站在线播放免费观看| 亚洲影院在线观看| 暖暖日本免费在线视频 | 18未年禁止免费观看| 亚洲欧洲无码AV不卡在线| 亚洲人午夜射精精品日韩| 99爱视频99爱在线观看免费| 亚洲精品自偷自拍无码| 黑人精品videos亚洲人| 嫖丰满老熟妇AAAA片免费看| 十八禁的黄污污免费网站| 亚洲系列国产精品制服丝袜第|