gpt4 book ai didi

c# - 将组合框数据从列表绑定(bind)到属性

转载 作者:行者123 更新时间:2023-12-03 10:55:04 24 4
gpt4 key购买 nike

我有一个 combo box和按钮

<ComboBox  ItemsSource="{Binding MessageTypesList}" 
DisplayMemberPath="MessageType"
SelectedValue="MessageType" />
<Button Content="Search"
Command="{Binding Path=SearchMessageTypes}"
x:Name="SearchMessageTypeButton"/>
MessageTypesList列表是从 SQL 查询生成的,一旦从列表中选择了消息类型,搜索按钮需要将所选值传递给我的 ViewMainModel 中的字符串属性。

当我调试应用程序时,传递给 MessageType 属性的值始终为 NULL。我有这个工作用于类似的日期时间搜索,但看不到如何将我的 XAML 中的 MessageType 值传递给 MessageType 属性表单绑定(bind)生成的列表。

最佳答案

您应该绑定(bind) SelectedValue属性到 View 模型中的属性。

关于c# - 将组合框数据从列表绑定(bind)到属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27582069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com