wpf中combobox选择

跟WINFORM以及WEB上不一样,例如这种是错误的:

 foreach ( ComboBoxItem item in this.cb_usertype.Items )
                {
                    item.IsSelected = CurrentModel.UserType == Convert.ToInt32(item.Tag);
                }

 

正确的写法:

 this.cb_usertype.SelectedIndex = CurrentModel.UserType;
原因没深究。

posted on 2013-04-02 11:04  而立未立  阅读(120)  评论(0)    收藏  举报