我刚开始学习WPF和C#。
考虑:
private void TransferAccountButtonClick(object sender, RoutedEventArgs e)
{
List<Client> allClients = Client.JsonToList();
TransferStackPanel.Visibility = Visibility.Visible;
TransferNameCombobox.DataContext = allClients;
TransferNameCombobox.DisplayMemberPath = "surname";
}
我需要在一个组合框中显示多个字段。事
TransferNameCombobox.DisplayMemberPath = "surname" + " " + "name" + " " + "patronymic";
如果我这样做,它将显示空字段。我明白“姓”不是一个字符串,但我不明白如何做到这一点。
在XAML中,我只有:
<ComboBox x:Name="TransferNameCombobox" ItemsSource="{Binding}"/>
1条答案
按热度按时间jhdbpxl91#
将
TransferNameCombobox.DataContext = allClients;
改为TransferNameCombobox.ItemsSource = allClients;
并删除TransferNameCombobox.DisplayMemberPath = "surname";
然后在xaml中,使用这个
MultiBinding
结构: