我正在尝试使用以下数据格式进行绑定:
Public Structure ItemBase
Property ID As String
Property Description As String
End Structure
Namespace Classes
Public Class StockEntityClass
Implements INotifyPropertyChanged
#Region "Property Variables"
Property ID As String
Property Namee As String
Property Units As String
Property ContactID As String
Property SetCount As Integer
Property VatOnMargin As Boolean
Property Vat As Double
Property Code As String
Property _ContactNamee As String
#End Region
Public Sub New()
_IDValue = Now.ToString
_NameeValue = ""
_UnitsValue = "Pcs"
_ContactIDValue = ""
_SetCountValue = 0
_VatOnMarginValue = False
_VatValue = 14.5
_CodeValue = ""
_ContactNamee = ""
End Sub
End Class
End Namespace
在作为 Stock Entity 变量的 DataContext 的 wpf xaml 窗口中,我有一个绑定到 BindingList(of ItemBase) 的组合框,用户将选择一个 Item 和该 ItemID 以与 StockEntity.ContactID 关联。
以下是 xaml 代码:
<ComboBox Name="VendorsComboBox" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" DisplayMemberPath="Description" SelectedItem="{Binding Path=CustomerID}"/>
以下是绑定代码:
Dim Stock As Classes.StockEntityClass
VendorsComboBox.ItemsSource = Contacts.DBAccessFunctions.Get_ContactsByType_BaseList(DataSource, "Vendor")
StockEntityStack.DataContext = Stock
StockEntityStack 包含 UI 部分,该部分是 datacontext 绑定到股票变量。您能否告诉我如何将 xaml 数据绑定到它。