Adding MapControl in xaml results in a “Catastropic failure”

后端 未结 2 1736
旧巷少年郎
旧巷少年郎 2021-01-17 14:12

I am creating an universal application using Visual Studio Ultimate 2013 Version 12.0.30501.00 Update 2. I am getting Catastrophic failure on adding Map Control in my xaml l

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 14:42

    I've come up with a workaround for this. Instead of using visibility you can use the maps height/width properties to hide/show the map. Set them to 0 when you want to hide it, and set it to the parents width/height when you want to show it. Here is a code sample:

    
    
        
            
            

    Button Handler:

    private void ShowMapBtn_Clicked(object sender, RoutedEventArgs e)
    {
        var mapContainer = MyMap.Parent as FrameworkElement;
        MyMap.Width = mapContainer.ActualWidth;
        MyMap.Height = mapContainer.ActualHeight;
    
        //Hide the button
        (sender as Button).Visibility = Visibility.Collapsed;
    }
    

提交回复
热议问题