Map.ContextMenu causes exception in WPF project
Closed this issue · 3 comments
I encountered an issue in my WPF application which uses MapControl. Whenever I right-click to bring up the context menu over the map, I get a weird exception that says that a ColumnDefinition cannot be converted to a Framework Element. There's a huge call stack which isn't very informative.
I reproduced it by creating a blank WPF .NET 8 C# application in Visual Studio 2022. I installed the latest MapControl via Nuget. This is what MainWindow.xaml looks like:
<Window x:Class="MapTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
xmlns:local="clr-namespace:MapTest"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<map:Map>
<map:Map.ContextMenu>
<ContextMenu>
</ContextMenu>
</map:Map.ContextMenu>
</map:Map>
</Window>
No edits to anything in other files which were automatically generated.
Right-clicking anywhere on the window causes the exception I mentioned.
Please try version 10.3.
Big thank you @ClemensFischer for fixing it so quickly. I also had this problem after updating from .net 7 to .net 8 👍.
Thank you very much for this absurdly fast fix! 😁