0

私はWindowsPhone7.5用のVBでアプリケーションを書いています

しかし、それはいくつかのバグがあります

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)

このエラーはなくなり、別のエラーが表示されます:

メソッド'PrivateSub 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

2つの文字列と1つのオブジェクトを結合しようとしていますが、これはできません。

lbi.Content(エラーのある行で)TextBlockであると強く疑うので、コードは「文字列、TextBlock、および文字列を連結する」と言います。
TextBlockに表示されるテキストが必要だと思われるので、それに応じてキャストします。

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