WPF Combox使用 Text无法选择正确获取CHange后的Text

使用固定ComboxItem 无法通过 selectitem as object 来进行回去到 Content内的对香数据。那我只能这个样干:

csharp 复制代码
 private void CBPaiweiLeixingSelect_Change(object sender, SelectionChangedEventArgs e)
        { 
            ComboBox ThisBox = sender as ComboBox;
            List<EDaxiaosuixi> ListShuixiE;
            ComboBoxItem SelectItemTextBox = CBPaiweiType.SelectedItem as ComboBoxItem;
            string SelectItemstr = SelectItemTextBox.Content as string;
            if (SelectItemstr == "非吉祥牌位")
            {
                ListShuixiE = ThisPaiweilist.Where(x => x.PaiweiType != EPaiweiType.吉祥牌位).Select(x => x.DaxiaoSuixi).Distinct().ToList();//获取大小随喜 
                CBPaiweiGuige.ItemsSource = ListShuixiE;
            }
            else if (SelectItemstr == "吉祥牌位")
            {
                ListShuixiE = ThisPaiweilist.Where(x => x.PaiweiType == EPaiweiType.吉祥牌位).Select(x => x.DaxiaoSuixi).Distinct().ToList();//获取大小随喜 
                CBPaiweiGuige.ItemsSource = ListShuixiE;
            }
        }

使用这个方法:

csharp 复制代码
 List<EDaxiaosuixi> ListShuixiE;
        ComboBoxItem SelectItemTextBox = CBPaiweiType.SelectedItem as ComboBoxItem;
        string SelectItemstr = SelectItemTextBox.Content as string;

SelectItemstr 就是要获取的便跟过来的数据。

相关推荐
三千道应用题几秒前
WPF&C#超市管理系统(6)订单详情、顾客注册、商品销售排行查询和库存提示、LiveChat报表
开发语言·c#·wpf
cpsvps_net13 小时前
美国服务器环境下Windows容器工作负载智能弹性伸缩
windows
甄超锋14 小时前
Java ArrayList的介绍及用法
java·windows·spring boot·python·spring·spring cloud·tomcat
cpsvps16 小时前
美国服务器环境下Windows容器工作负载基于指标的自动扩缩
windows
✎ ﹏梦醒͜ღ҉繁华落℘18 小时前
开发WPF项目时遇到的问题总结
wpf
网硕互联的小客服19 小时前
Apache 如何支持SHTML(SSI)的配置方法
运维·服务器·网络·windows·php
etcix19 小时前
implement copy file content to clipboard on Windows
windows·stm32·单片机
许泽宇的技术分享20 小时前
Windows MCP.Net:基于.NET的Windows桌面自动化MCP服务器深度解析
windows·自动化·.net
非凡ghost21 小时前
AMS PhotoMaster:全方位提升你的照片编辑体验
windows·学习·信息可视化·软件需求
mortimer1 天前
一次与“顽固”外部程序的艰难交锋:subprocess 调用exe踩坑实录
windows·python·ai编程