Code |
Code |
Code |
Code |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Santhosh NRank #4,788 · 325 reputationPosted Jan 5, 2010, 10:53 PM EST
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!";
}
Sven Nijs14 reputationPosted Jan 5, 2010, 11:12 PM EST
myLayer.someproperty = kp_naam;
But "someproperty" is red underlined...
Santhosh NRank #4,788 · 325 reputationPosted Jan 5, 2010, 11:18 PM EST
try to use .Text or any other property of the control which you have any properties existing and check..
Sven Nijs14 reputationPosted Jan 5, 2010, 11:26 PM EST
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 NRank #4,788 · 325 reputationPosted Jan 5, 2010, 11:38 PM EST
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 Nijs14 reputationPosted Jan 5, 2010, 11:51 PM EST
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 ;-)
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Jan 6, 2010, 12:19 AM EST
private void OverKnooppunt(object sender, MouseEventArgs e)
{
MapLayer obj = (MapLayer)sender;
string kp = obj.Tag;
knooppunt.Text = "8";
}
Santhosh NRank #4,788 · 325 reputationPosted Jan 6, 2010, 12:22 AM EST
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..
Sven Nijs14 reputationPosted Jan 6, 2010, 2:38 AM EST
Santhosh NRank #4,788 · 325 reputationPosted Jan 6, 2010, 5:08 AM EST
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