Vb.net Xaml数据绑定

Vb.net Xaml数据绑定,vb.net,silverlight,data-binding,Vb.net,Silverlight,Data Binding,我有下面的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 Propert

我有下面的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>

在ouput窗口中,我收到以下错误消息:


无法从“SNC.CommonStock.SelectedPart”(类型“SNC.CommonStock.SelectedPart”)获取“Part_Id”值(类型“System.String”)。BindingExpression:Path='Part\u Id'DataItem='SNC.CommonStock.SelectedPart'(HashCode=53866394);目标元素是“System.Windows.Controls.Label”(名称=“”);目标属性为“Content”(类型为“System.Object”)。。System.MethodAccessException:尝试通过方法“System.Windows.CLRPropertyListener.get_Value()”访问方法“SNC.CommonStock.SelectedPart.get_Part_Id()”失败。

标签目前都是相互重叠的,如果没有描述,则可能看不到任何内容。将标签放置在
堆栈面板中

我必须使我绑定到的类公开

没有StringFormat它可以工作吗没有StringFormat它不能删除StringFormat我一开始尝试了一下,但没有解决它。我刚刚在输出中看到这个错误-无法从“SNC.CommonStock.SelectedPart”(类型“SNC.CommonStock.SelectedPart”)获取“Part_Id”值(类型“System.String”)。BindingExpression:Path='Part\u Id'DataItem='SNC.CommonStock.SelectedPart'(HashCode=53866394);目标元素是“System.Windows.Controls.Label”(名称=“”);目标属性为“Content”(类型为“System.Object”)。。System.MethodAccessException:尝试使用方法'System.Windows.CLRPropertyListener.get_Value()'访问方法'SNC.CommonStock.SelectedPart.get_Part_Id()'失败。@Jim:我不做VB.NET,但在C中,类是内部的(我认为用VB的说法是朋友),属性是私有的,除非您另行指定。为了使绑定工作,类和属性都需要是公共的。所以我想知道你是否需要向类和属性添加公共可访问性。是的,就是这样。我把答案贴在下面。看起来我们差不多是在同一时间发布的:)