Freestyle Coding

Programming in the Real World

  Home  |   Contact  |   Syndication    |   Login
  57 Posts | 0 Stories | 41 Comments | 0 Trackbacks


Tag Cloud


Post Categories





Social Networks

I've spent the past couple of days adding the Bing Maps WFP Control to an application I'm developing. I kept running into a strange thing that was driving me crazy. I have the control in the bottom of a StackPanel, under a Grid. No matter how hard I tried, setting the Height of the Bing control to Auto would cause the ActualHeight to always be 60.93.

Now, I still don't know why this is happening. Truth be told, I'm not too sure I care. I did, however, find a reasonable hack around the problem. I do know the size of everything else. As such, I tied into the SizeChanged Event of the StackPanel. Using this, I could set the Height to the correct size based on the new size of the panel.

private void ResizeMap( object sender, SizeChangedEventArgs e ) {
myMap.Height = ((StackPanel)sender).ActualHeight - 75.0;
The hard-coded number is was because I had a fixed height of controls above my map. If you have dynamic elements, you could easily iterate through them and delete out the portions.

So, there you have it. It's not much, but it annoyed the Smurf out of me for a brief period of time. Since I never found an answer, I figured I'd share.

posted on Friday, October 5, 2012 1:50 PM