I am working on this desktop program as a school project in C# and working with WPF, currently I am trying to get the users location using Bing maps and the LocationApiLibrary. Had a few problems with some missing references but I managed to sort it out. Now i am getting this error:
Error CS1503 Argument 2: cannot convert from 'LocationApiLib.Location' >to 'Microsoft.Maps.MapControl.WPF.Location'
I have searched, even here but without finding something that can solve my problem. Basically I want to be able to read the coordinates of the client and show them in a textbox, and save it together with the some other information in the database.
using LocationApiLib;
using Microsoft.Maps.MapControl.WPF;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace myBMark_Dekstop_Edition
{
/// <summary>
/// Interaction logic for Window2.xaml
/// </summary>
public partial class Window2 : Window
{
private myMap;
public Window2()
{
InitializeComponent();
ImageBrush myBrush = new ImageBrush();
myBrush.ImageSource =
new BitmapImage(new Uri("C:/Users/AbdulB.M/Documents/Visual Studio 2015/Projects/myBMark Dekstop Edition/1.PNG", UriKind.Absolute));
this.Background = myBrush;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
LocationApiLib.Location myLoc = new LocationApiLib.Location();
myMap.SetView(myLoc, Convert.ToDouble(14), Convert.ToDouble(0));
Pushpin myPin = new Pushpin();
MapLayer.SetPosition(myPin, myLoc);
myMap.Children.Add(myPin);
System.Windows.Controls.Label label = new System.Windows.Controls.Label();
label.Content = "Here I am!";
label.Foreground = new SolidColorBrush(Colors.DarkBlue);
label.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
label.FontSize = 30;
MapLayer.SetPosition(label, myLoc);
myMap.Children.Add(label);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
}
}
}
Xaml part is here:
<Window x:Class="myBMark_Dekstop_Edition.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:myBMark_Dekstop_Edition"
mc:Ignorable="d"
Title="Home" Height="634.695" Width="695.732" WindowStartupLocation="CenterScreen">
<Grid>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="72,160,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="23" Margin="72,207,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="textBox2" HorizontalAlignment="Left" Height="23" Margin="72,271,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="textBox3" HorizontalAlignment="Left" Height="23" Margin="72,320,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="textBox4" HorizontalAlignment="Left" Height="23" Margin="72,377,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="textBox5" HorizontalAlignment="Left" Height="23" Margin="72,117,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<m:Map Name="myMap"
Center="-1.968404, 30.036240"
ZoomLevel="10"
CredentialsProvider="..."
Mode="Road" Margin="245,29,29.6,347.8" ></m:Map>
<StackPanel HorizontalAlignment="Left"/>
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Content="+" Click="Button_Click_1" Width="105" Height="40"/>
<Button Content="-" Click="Button_Click_2" Width="105" Height="40"/>
</StackPanel>
<Button Content="Get my location" Click="Button_Click" Margin="396,275,188.6,302.8"/>
</Grid>