2013-06-05 3 views
5

へのC#からのコード行を変換するために、私はこのコードを翻訳して1行にいくつかの助けを必要とする:C#でどのようにビジュアルBaisc

オリジナル:

using System.Collections.ObjectModel; 
using Microsoft.Maps.MapControl; 

namespace Binding_Bing_Map_Control.Modal 
{ 
public class MapModal 
{ 
    public Location MapLocation { get; set; } 
    public string TooltipText { get; set; } 

    public static ObservableCollection<MapModal> getMapRecords() 
    { 
     ObservableCollection<MapModal> MapRecords = new ObservableCollection<MapModal>(); 
     MapRecords.Add(new MapModal() { MapLocation = new Location(47.610015, -122.188362), TooltipText = "Main St, Bellevue, WA 98004" }); 
     MapRecords.Add(new MapModal() { MapLocation = new Location(47.603562, -122.329496), TooltipText = "James St, Seattle, wa 98104" }); 
     MapRecords.Add(new MapModal() { MapLocation = new Location(47.609355, -122.189970), TooltipText = "Main St, Bellevue, WA 98004-6405" }); 
     MapRecords.Add(new MapModal() { MapLocation = new Location(47.615820, -122.238973), TooltipText = "601 76th Ave, Medina ,WA 98039" }); 
     return MapRecords; 
    } 
} 
} 

VBへの私の翻訳:

Imports System.Collections.ObjectModel 
Imports Microsoft.Maps.MapControl 

Namespace Map_Control.Modal 

Public Class MapModal 

    Public Property Location As WPF.Location 
    Public Property TooltipTex As String 

    Public Function getMapRecors() As ObservableCollection(Of MapModal) 
     Dim MapRecords As New ObservableCollection(Of MapModal) 
     MapRecords.Add(New MapModal() {Location = New WPF.Location(47, -122), TooltipTex = "Sample tooltiptext!"}) 
     Return MapRecords 
    End Function 

End Class 

End Namespace 

私は行でエラーが発生します。

MapRecords.Add(New MapModal() {Location = New WPF.Location(47, -122), TooltipTex = "Sample tooltiptext!"}) 

エラー:Boolean型の値をWindowsApplication1.Map_Control.Modal.MapModalに変換できません。

私は何をしているのかを明確にするためです。私はwpfアプリケーションを構築しようとしており、bingマップを使用しています。私はこのlink.のコードに従っていますが、Silverlightを使用していないため、VBでコーディングしています。

+1

1を、単に "私のコードを私のために変換する"とは言いません。 –

+0

+1 - @Evanlewisと同じです - 他の翻訳質問を – Sayse

+0

にリンクするための質問として役立ちます。誰もがここで別の "このすべてのコードを私のために変換する"と期待していたと思います – SysDragon

答えて

5

このような何か試してみてください:固有の翻訳質問の

MapRecords.Add(New MapModal() With {.Location = New WPF.Location(47, -122), .TooltipTex = "Sample tooltiptext!"}) 
+0

メディノックさん、ありがとうございました。 – micco

1

私はこの問題はここにあると思う:

public Location MapLocation { get; set; } 

この行は

Public Property Location As WPF.Location 

に変換することができない私はあなたが場所のクラスをいじりだと思います。 WPF名前空間への参照がC#バージョンには存在しないことに注意してください。構文initialiazer

+0

私はさまざまな参考文献を使用しています。元の参照ポイントは 'silverlight maps api'です。ここでは 'wpf maps api'を使用しています。 – micco

1

オブジェクトは、VB.Netで異なっている - 私はan online translatorを使用し、これを得た:

Imports System.Collections.ObjectModel 
Imports Microsoft.Maps.MapControl 

Namespace Binding_Bing_Map_Control.Modal 
    Public Class MapModal 

     Public Property Location As Location 
     Public Property TooltipTex As String 

     Public Shared Function getMapRecords() As ObservableCollection(Of MapModal) 
      Dim MapRecords As New ObservableCollection(Of MapModal)() 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.610015, -122.188362), _ 
       Key .TooltipText = "Main St, Bellevue, WA 98004" _ 
      }) 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.603562, -122.329496), _ 
       Key .TooltipText = "James St, Seattle, wa 98104" _ 
      }) 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.609355, -122.18997), _ 
       Key .TooltipText = "Main St, Bellevue, WA 98004-6405" _ 
      }) 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.61582, -122.238973), _ 
       Key .TooltipText = "601 76th Ave, Medina ,WA 98039" _ 
      }) 
      Return MapRecords 
     End Function 
    End Class 
End Namespace 
関連する問題