c# - 组合框从列表中添加项目
问题描述
我有一个组合框,我想将列表填充到其中。目前,我可以填充列表,但无法显示它的字符串。
这是从组合框中显示的输出:
solution_name.folder_name.class_name
这是我的用户 C# 代码:
userRoleList.Add(new User()
{
UserRole = reader[1].ToString()
});
这是我的 xaml 代码:
<ComboBox x:Name="cbUserRole" FlowDirection="LeftToRight" FontSize="16" Foreground="MidnightBlue" HorizontalAlignment="Stretch" VerticalAlignment="Center" ItemsSource="{Binding}"/>
这是我的 viewuser c# 代码:
var userRolesList = new User().getUserRoles();
ComboBox cbUserRole = (ComboBox)GetChildren(userDataGrid).First(x => x.Name == "cbUserRole");
cbUserRole.ItemsSource = userRolesList;
如何在组合框中显示字符串?
解决方案
推荐阅读
- ios - 展开可选值 nil
- scala - 在多个分区上工作
- java - Selenium UnreachableBrowserException - Java
- java - 通过 PublishSubject 在 onNext 中传递 null 并在 RxJava 中过滤该响应
- c - %typemap 指令未在 SWIG 中编译
- ssl - 使tomcat中的“crlFile”属性动态化
- javascript - React:将按钮的状态设置为禁用使得无法勾选复选框
- c# - Xamarin.Forms - PropertyChanged set {} 未调用
- go - Go 程序在使用错误代码调用其他程序后结束
- php - 在 laravel 中验证表单时出错