0

我正在用 VB 为 windows phone 7.5 编写一个应用程序

但它有一些错误

Imports System.IO
Imports System.IO.TextReader
Imports System.Xml
Imports System.Windows.RoutedEventArgs
Imports System.Windows.RoutedEvent
Imports System.ComponentModel
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports Microsoft.Phone.Tasks
Imports System.Xml.Linq 
Imports System.Net.NetworkInformation
Imports Microsoft.VisualBasic.CompilerService

Partial Public Class MainPage
    Inherits PhoneApplicationPage

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEventArgs)             Handles MyBase.Loaded
        Final.Items.Clear()
        If NetworkInterface.GetIsNetworkAvailable Then
            Dim cl As New WebClient
            AddHandler cl.DownloadStringCompleted, AddressOf cl_DownloadStringCompleted
            cl.DownloadStringAsync(New Uri("http://web.com/xml.xml"))
        Else
            MessageBox.Show("check your internet connection")
        End If
    End Sub


    Private Sub cl_DownloadStringCompleted(sender As Object, e As System.Net.DownloadStringCompletedEventArgs)
        Dim doc = XDocument.Parse(e.Result)
        Dim names = XDocument.Parse(e.Result)
        Dim result_name = names.<Data>.<Entry>
        For Each result In doc.<Data>.<Entry>.<tag>
            Dim item As New ListBoxItem
            item.Content = result.Value
            AddHandler item.Tap, AddressOf ItemTap
            Final.Items.Add(item)
        Next
    End Sub

    Private Sub ItemTap(sender As Object, e As GestureEventArgs)
        Dim lbi As New ListBoxItem
        lbi = sender
        Dim url As New Uri("/" & lbi.Content & ".xaml", UriKind.Relative)
        Me.NavigationService.Navigate(url)
    End Sub

End Class

它发现了一个错误Dim url As New Uri("/" & lbi.Content & ".xaml", UriKind.Relative)

它在报告中说:

请求的操作不可用,因为未定义运行时库函数“Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject”。

注意:当我将 ItemTap 更改为此: Private Sub ItemTap(ByRef sender As Object, e As GestureEventArgs)

此错误消失并出现另一个错误:

方法 'Private Sub ItemTap(ByRef sender As Object, e As System.Windows.Input.GestureEventArgs)' 没有与委托 'Delegate Sub EventHandler(Of System.Windows.Input.GestureEventArgs)(sender As Object, e作为 System.Windows.Input.GestureEventArgs)'。

在行:“AddHandler item.Tap,AddressOf ItemTap”

任何想法为什么我有这个?谢谢你 !

4

1 回答 1

1

您正在尝试组合两个字符串和一个对象,但它不能这样做。

我强烈怀疑lbi.Content(在出错的行中)是一个 TextBlock,所以你的代码说“将一个字符串、一个 TextBlock 和一个字符串连接在一起”。
我怀疑你想要在 TextBlock 中显示的文本,所以只需相应地转换它:

"/" & DirectCast(lbi.Content, TextBlock).Text & ".xaml"
于 2012-05-14T08:39:26.943 回答