wpf 中获取ComboBox中选定的文本值

在网上搜的不对,我就自己写了个。

使用combobox的SelectionChanged事件。

private void Combobox_change(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                string ss = "";
                ss = ((System.Windows.Controls.ComboBoxItem)e.AddedItems[0]).Content.ToString();                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);    
                throw;
            }
        }

倒是也挺简单的。

posted @ 2012-10-15 15:30  _倔强  阅读(1721)  评论(0编辑  收藏  举报