gpt4 book ai didi

wpf - 如何使用 WPF 数据绑定(bind)处理外键?

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

我在 WPF 中有一个 ListView,它数据绑定(bind)到我从数据库中提取的基本表。 ListView 的代码如下:

<ListView Canvas.Left="402" Canvas.Top="480" Height="78" ItemsSource="{Binding}" Name="lsvViewEditCardPrint" Width="419">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=IdCst}">Set</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=Language}">Language</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=Number}">Number</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=IdArt}">Artwork</GridViewColumn>
</GridView>
</ListView.View>
</ListView>

IdCst 列是单独表的外键,我想显示该表中的实际名称字段,而不仅仅是 Id。有谁知道如何设置数据绑定(bind),或者是否有一个事件,例如 OnItemDataBound,我可以拦截以修改显示?

最佳答案

本博客 post可能有帮助:

...I assumed the foreign key should be bound to the ‘SelectedValue’ property, and there is an ItemSource that I can bind to my fact table so the drop down is populated.

At this point my dropdown worked, but nothing would appear in the combobox. I finally noticed a ‘SelectedItemPath’ property - I assumed this would be the name of the field in my dropdown that was associated to my foreign key. Sure enough, that’s exactly what it is.

关于wpf - 如何使用 WPF 数据绑定(bind)处理外键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/195151/

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