You're good, in this way it works ;-). Thank you very much! When you need more arguments it will be difficult... But at this time I don't need more arguments.
I dont have visual studio in front of me at present and hence could not check but give this a try and I am sure this should work for you..
private void OverKnooppunt(object sender, MouseEventArgs e) { MapLayer mLayer = (MapLayer)sender;
string kp = mLayer.Tag; knooppunt.Text = "8"; }
If it gives any error try to instantiate the mLayer variable first and then assign the sender as typecasted..
This error occured:
Error 1 Cannot implicitly convert type 'object' to 'Microsoft.Maps.MapControl.MapLayer'. An explicit conversion exists (are you missing a cast?) E:\Silverlight\Bing_Maps_App\Bing_Maps_App\MainPage.xaml.cs 204 22 Bing_Maps_App
"sender" en "sender.Tag" are red underlined.
There is no other manner to give an argument with function Overknooppunt ;-)
you need to typecast the sender object to the actual type before accessing its properties..
something like this...
private void OverKnooppunt(object sender, MouseEventArgs e) {
var mLayer = new MapLayer();
mLayer = sender;
string kp = mLayer.Tag; knooppunt.Text = "8"; }
Please mark as accepted if it solves your problem
Ok, I post my two functions, I did wat you say but in the second function ".Tag" is red underlined...
public void PlaatsKnooppunt(string latitude, string longitude, string kp_naam)
{
var location = new Location(double.Parse(latitude), double.Parse(longitude));
var myLayer = new MapLayer();
var rectangle = new System.Windows.Shapes.Rectangle();
rectangle.Width = 10;
rectangle.Height = 10;
rectangle.Fill = new SolidColorBrush(Colors.Green);
PositionOrigin position = PositionOrigin.Center;
what i meant to say "someproperty" is not exactly same but something like .Text or any other property :)
try to use .Text or any other property of the control which you have any properties existing and check..
you could actually have desired values added to the object that is rasinig the event
mylayer.someproperty = ur value;
myLayer.MouseEnter += new MouseEventHandler(OverKnooppunt);
and you could access that in the event
private void OverKnooppunt(object sender, MouseEventArgs e) {
sender.someproperty knooppunt.Text = "Hallo!"; }
Santhosh NPosted Jan 6, 2010, 10:08 AM
abc;xyz;pqr
and you can read from the .tag abd split them on ; and read them
--------------------------------------------------------------------------------------
Can you please Mark as Accepted as I see it solves your problem
Sven NijsPosted Jan 6, 2010, 7:38 AM
Santhosh NPosted Jan 6, 2010, 5:22 AM
private void OverKnooppunt(object sender, MouseEventArgs e)
{
MapLayer mLayer = (MapLayer)sender;
string kp = mLayer.Tag;
knooppunt.Text = "8";
}
If it gives any error try to instantiate the mLayer variable first and then assign the sender as typecasted..
Nilanka DharmadasaPosted Jan 6, 2010, 5:19 AM
private void OverKnooppunt(object sender, MouseEventArgs e)
{
MapLayer obj = (MapLayer)sender;
string kp = obj.Tag;
knooppunt.Text = "8";
}
Sven NijsPosted Jan 6, 2010, 4:51 AM
Error 1 Cannot implicitly convert type 'object' to 'Microsoft.Maps.MapControl.MapLayer'. An explicit conversion exists (are you missing a cast?) E:\Silverlight\Bing_Maps_App\Bing_Maps_App\MainPage.xaml.cs 204 22 Bing_Maps_App
"sender" en "sender.Tag" are red underlined.
There is no other manner to give an argument with function Overknooppunt ;-)
Santhosh NPosted Jan 6, 2010, 4:38 AM
something like this...
private void OverKnooppunt(object sender, MouseEventArgs e)
{
var mLayer = new MapLayer();
mLayer = sender;
string kp = mLayer.Tag;
knooppunt.Text = "8";
}
Please mark as accepted if it solves your problem
Sven NijsPosted Jan 6, 2010, 4:26 AM
public void PlaatsKnooppunt(string latitude, string longitude, string kp_naam)
{
var location = new Location(double.Parse(latitude), double.Parse(longitude));
var myLayer = new MapLayer();
var rectangle = new System.Windows.Shapes.Rectangle();
rectangle.Width = 10;
rectangle.Height = 10;
rectangle.Fill = new SolidColorBrush(Colors.Green);
PositionOrigin position = PositionOrigin.Center;
myLayer.AddChild(rectangle, location, position);
myLayer.Tag = kp_naam;
myLayer.MouseEnter += new MouseEventHandler(OverKnooppunt);
BingMap.Children.Add(myLayer);
}
private void OverKnooppunt(object sender, MouseEventArgs e)
{
string kp = sender.Tag;
knooppunt.Text = "8";
}
Santhosh NPosted Jan 6, 2010, 4:18 AM
try to use .Text or any other property of the control which you have any properties existing and check..
Sven NijsPosted Jan 6, 2010, 4:12 AM
myLayer.someproperty = kp_naam;
But "someproperty" is red underlined...
Santhosh NPosted Jan 6, 2010, 3:53 AM
mylayer.someproperty = ur value;
myLayer.MouseEnter += new MouseEventHandler(OverKnooppunt);
and you could access that in the event
private void OverKnooppunt(object sender, MouseEventArgs e)
{
sender.someproperty
knooppunt.Text = "Hallo!";
}