我有下面的xaml,我試圖綁定到我的課程。我無法使值顯示出來。任何人都可以向我指出我失蹤的方向。先謝謝你。Xaml數據綁定
Dim frm As New EditPart
frm.DataContext = New SelectedPart(_CPPartPicker.Selected_Part, "ABC")
frm.Show()
Class SelectedPart
Property Part_Key As Integer
Property Part_Id As String
Property Part_Rev As String
Property Whse As String
Property Part_Description As String
Sub New(Part As SNC.SL.Common.CP_Item.CP_Item_Lookup_Version_1Item_Lookup_Response, Whse As String)
Part_Key = Part.ITEM_KEY
Part_Id = Part.ITEM_ID
Part_Rev = Part.ITEM_RVSN_ID
Whse = Whse
Part_Description = Part.ITEM_DESC
End Sub
末級
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sdk:Label Content="{Binding Path=Part_Id, StringFormat='Part ID: \{0}'}" />
<sdk:Label Content="{Binding Path=Part_Rev, StringFormat='Part Rev: \{0}'}" />
<sdk:Label Content="{Binding Path=Part_Description, StringFormat='Description: \{0}'}"/>
<Button x:Name="CancelButton" Content="Cancel" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
<Button x:Name="OKButton" Content="OK" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
</Grid>
在輸出中窗口我得到的下面的錯誤消息:
無法從「SNC.CommonStock 'PART_ID' 值(類型 'System.String') .SelectedPart'(輸入'SNC.CommonStock.SelectedPart')。 BindingExpression:Path ='Part_Id'DataItem ='SNC.CommonStock.SelectedPart'(HashCode = 53866394);目標元素是'System.Windows.Controls.Label'(Name =''); System.MethodAccessException:嘗試通過方法'System.Windows.CLRPropertyListener.get_Value()'來訪問方法'SNC.CommonStock.SelectedPart.get_Part_Id()'失敗。
它並沒有的StringFormat –
工作沒有不與拆卸的StringFormat – Jim