1. 程式人生 > >談一談關於Combox中當SelectedIndex="0" 無效的問題

談一談關於Combox中當SelectedIndex="0" 無效的問題

最近在做一個專案,combox繫結資料來源之後,有些SelectedIndex="0" 是有值的,有些沒值,百思不得其解,今天專門花時間研究下這個問題,終於搞定!!!!

重點在SelectedValuePath這個屬性,SelectedValuePath繫結的值==int?型別,SelectedIndex="0"有效,
                                                    SelectedValuePath繫結的值!=int?型別,SelectedIndex="0"無效,

設定SelectIndex屬性,就須設定SelectedValuePath,SelectedValue,且型別都須是int?型別

看下示例:

有值

改成:int

無效