用于Windows手机的VB silverlight

时间:2012-05-13 20:52:52

标签: vb.net silverlight windows-phone-7

我正在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)(发送者为对象,e为   System.Windows.Input.GestureEventArgs)”

     

at line:“AddHandler item.Tap,AddressOf ItemTap”

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

1 个答案:

答案 0 :(得分:1)

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

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

"/" & DirectCast(lbi.Content, TextBlock).Text & ".xaml"