简体   繁体   English

UWP MapControl inW WPF 应用程序使用 XAML 岛

[英]UWP MapControl inW WPF app using XAML Islands

I have included a MapControl in my WPF Core application using these instructions .使用这些说明在我的 WPF 核心应用程序中包含了一个 MapControl。 I can correctly display the map but the problem is when I try to place any other interface element on top of the map.我可以正确显示 map 但问题是当我尝试在 map 顶部放置任何其他界面元素时。 I have tried many ways but the map always overlays any other element I place on top of it, and therefore does not display.我尝试了很多方法,但 map 总是覆盖我放在它上面的任何其他元素,因此不会显示。 For example:例如:

<Window x:Class="WpfMapControl.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:local="clr-namespace:WpfMapControl"
    xmlns:controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
    mc:Ignorable="d"
    Title="MainWindow" Height="400" Width="400">
<Grid>
    <controls:MapControl Grid.Column="1"
                x:Name="mapControl"/>
    <Rectangle Width="100" Height="100" Fill="Red"></Rectangle>
</Grid>

This should look like this:这应该是这样的:

在此处输入图像描述

But the result is this:但结果是这样的:

在此处输入图像描述

How can I place any other element on top of the MapControl?如何在 MapControl 上放置任何其他元素?

How can I place any other element on top of the MapControl?如何在 MapControl 上放置任何其他元素?

Short answer: You can't.简短的回答:你不能。

Just like a Windows Forms control in a WindowsFormsHost , a WindowsXamlHost is hosted in a separate HWND that is always drawn on top of the WPF elements.就像WindowsFormsHost中的 Windows Forms 控件一样, WindowsXamlHost托管在一个单独的 HWND 中,该 HWND始终绘制在 Z3055DD731D79EAA7189A62F36724E09F 元素之上。

From the docs :文档

A hosted Windows Forms control is drawn in a separate HWND, so it is always drawn on top of WPF elements.托管的 Windows Forms 控件绘制在单独的 HWND 中,因此它始终绘制在 WPF 元素的顶部。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM