Skip to main content
Home Forums Silverlight Programming Programming with .NET - General VE map in Silverlight
2 replies. Latest Post by darkcrawler on October 3, 2008.
(0)
darkcrawler
Member
25 points
20 Posts
10-01-2008 8:28 AM |
Hi there!
I'm trying to get a VE map in my application. I can do that... The thing is, I just want to show the map when i press a button.
My idea is, have the mapContainer div hidden (or width and height with value 0) and when i press the button, change the div style! But does not wok!
Can you help me?
.aspx code:
<head>
...
<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></script><script type="text/javascript" src="views.js"></script>
</head>
<body> <div id='errorLocation' style="font-size: small;color: Gray;"></div> <div id="silverlightControlHost"> <form id="form1" runat="server" style="height: 100%;"> <div id='mapContainer' runat="server" style="visibility: hidden; position: absolute;"> </div> <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" width="100%" height="100%"> <param name="source" value="ClientBin/MapTeste.xap"/> <param name="onerror" value="onSilverlightError" /> <param name="background" value="white" /> <param value="true" name="windowless"/> <a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> </a> </object> <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe> </form> </div></body>
page.xaml.cs code:
private VEMap map; public Page() { InitializeComponent(); }
private void test_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { map = new VEMap("mapContainer"); HtmlPage.RegisterScriptableObject("SLMAP", map); HtmlElement m = HtmlPage.Document.GetElementById("mapContainer"); if (m != null) { m.SetStyleAttribute("left", "50"); m.SetStyleAttribute("right", "50"); m.SetStyleAttribute("width", "320"); m.SetStyleAttribute("height", "240"); m.SetStyleAttribute("visibility", "visible"); } map.LoadMap(); } }
pade.xaml code:
<Grid x:Name="LayoutRoot" Background="White"> <Button x:Name="teste" Width="80" Height="20" Content="testar" MouseLeftButtonDown="test_MouseLeftButtonDown"></Button> </Grid>
Yi-Lun L...
All-Star
25052 points
2,747 Posts
10-03-2008 12:45 AM |
Hello, I didn't test Virtual Earth. But I think your problem is you're trying to handle a Button's MouseLeftButtonDown event. Why don't handle the Click event? MouseLeftButtonDown is handled by Button internally and marked as Handled, so you won't get it. Use Click instead. If you want the event handler to be invoked as soon as the mouse button is down, set the Button's ClickMode to Press.
10-03-2008 8:46 AM |
Ok...
Works fine with the Click event!
I had other wrong things, but is working now...
Thanks