wpf comboBox取值问题

这是获取值后台代码    

private void button1_Click(object sender, RoutedEventArgs e)
        {
            combBox = this.comboBox1.SelectedItem as ComboBoxItem;
            combBox1 = this.comboBox2.SelectedItem as ComboBoxItem;
            string type = combBox.Content.ToString();
            string type1 = combBox1.Content.ToString();
            MessageBox.Show(type+type1);
        }
        ComboBoxItem combBox;
        ComboBoxItem combBox1;
        string value = "";
        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem cbItem = (ComboBoxItem)(sender as ComboBox).SelectedItem;
            value = cbItem.Content.ToString();
            MessageBox.Show(value);

          // string v = (sender as ComboBox).SelectedValue.ToString();
           // string bx=  v as string;
           // MessageBox.Show(bx);
       
        }

posted @ 2014-04-19 11:58  天翊无影  阅读(1994)  评论(0编辑  收藏  举报