获得在C#WPF从组合框中选择的值 [英] Get selected value from combo box in c# wpf

查看:371
本文介绍了获得在C#WPF从组合框中选择的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这可能是一个愚蠢的问题,但我不能找到它在互联网上。

i think this might be a stupid question but I can't find it on the internet.

使用WPF的形​​式,而不是WF形式我刚刚开始。在WF形式我只是做:

I have just started using WPF forms instead of WF forms. In a WF form I could just do:

ComboBox.SelectedValue.toString();



,这将正常工作。

and this would work fine.

这怎么它似乎我在WPF不具有的选项。

How do I do this in WPF it doesn't seem to have the option.

感谢

推荐答案

我已经想通了有点怪做着它相比老WF形式的方式:

I have figured it out a bit of strange way of doing it compared to the old WF forms:

ComboBoxItem typeItem = (ComboBoxItem)cboType.SelectedItem;
string value = typeItem.Content.ToString();

这篇关于获得在C#WPF从组合框中选择的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆