组合框从列表中添加项目

时间:2018-09-04 08:42:16

标签: c# wpf

我有一个组合框,我想在其中填充列表。 目前,我可以填充列表,但是无法显示其字符串。

以下是组合框中显示的输出:

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;

如何在组合框中显示字符串?

0 个答案:

没有答案
相关问题