Vb.net 绑定到类内部属性的XAML TextBox

Vb.net 绑定到类内部属性的XAML TextBox,vb.net,xaml,windows-phone-8.1,Vb.net,Xaml,Windows Phone 8.1,好的,我正在尝试在Windows Phone应用程序中设置一个页面,该页面将有一个包含两个组的LongListSelector,并且在每个组中可以显示不同类型的数据。我能够设置一个TemplateSelector,为不同类型的对象选择正确的数据模板,但我似乎无法深入到数据源中实际值的正确绑定路径。我将尝试发布所有相关代码,看看这是否有帮助 'These are the classes that are used for the Datasource, there are 2 specif

好的,我正在尝试在Windows Phone应用程序中设置一个页面,该页面将有一个包含两个组的LongListSelector,并且在每个组中可以显示不同类型的数据。我能够设置一个TemplateSelector,为不同类型的对象选择正确的数据模板,但我似乎无法深入到数据源中实际值的正确绑定路径。我将尝试发布所有相关代码,看看这是否有帮助

    'These are the classes that are used for the Datasource, there are 2 specific classes and then one class to use for the data source that will contain a type value and then one of the 2 specific classes
 Public Class ActionItemsClass
        Public Property type As String
        Public Property alertItem As AlertClass
        Public Property btrItem As BTRClass
    End Class

    Public Class AlertClass
        Public Property asOfDate As String
        Public Property subject As String
        Public Property text As String

    End Class

    Public Class BTRClass
        Public Property id As String
        Public Property policyID As String
        Public Property fromUser As String
        Public Property txnNumber As String
        Public Property createdDate As String
        Public Property contactID As String
        Public Property contactName As String
        Public Property productName As String
        Public Property investmentAmount As String
        Public Property btrNote As String
        Public Property currentStatus As String
        Public Property response As String

    End Class
这里是模板选择的XAML代码,正如您所看到的,我一直在尝试各种方法来获取要显示的数据(目前每个类中只有一个项作为测试),但到目前为止,唯一显示的是组头,并且创建的数据源没有任何问题

<DataTemplate x:Key="alertItem">
            <TextBlock DataContext="{Binding AlertClass}" Text="{Binding text}" Foreground="Red"/>
        </DataTemplate>
        <DataTemplate x:Key="btrItem">
            <TextBlock Text ="{Binding Path=btrItem.btrNote}" Foreground="Green"/>
        </DataTemplate>
        <DataTemplate x:Key="SelectingTemplate">
            <local:TemplateSelector AlertTemplate ="{StaticResource alertItem}"
                                    BTRTemplate="{StaticResource btrItem}"/>

我认为您需要像这样绑定文本块

<TextBlock Text="{Binding AlertClass.text}" Foreground="Red"/>

事实上,我发现了问题,我首先需要在SelectingTemplate中添加一个“Content={Binding}”,然后alertItem.text绑定工作。谢谢