【问题标题】:UWP MapControl inW WPF app using XAML IslandsUWP MapControl inW WPF 应用程序使用 XAML 岛
【发布时间】:2021-05-27 01:04:23
【问题描述】:

我在我的 WPF Core 应用程序using these instructions 中包含了一个 MapControl。我可以正确显示地图,但问题是当我尝试在地图顶部放置任何其他界面元素时。我尝试了很多方法,但地图总是覆盖我放在它上面的任何其他元素,因此不会显示。例如:

<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>

这应该是这样的:

但是结果是这样的:

如何在 MapControl 上放置任何其他元素?

【问题讨论】:

    标签: c# wpf xaml uwp xaml-islands


    【解决方案1】:

    如何在 MapControl 上放置任何其他元素?

    简短回答:你不能。

    就像WindowsFormsHost 中的 Windows 窗体控件一样,WindowsXamlHost 托管在一个单独的 HWND 中,该 HWND总是绘制在 WPF 元素之上。

    来自docs

    托管的 Windows 窗体控件在单独的 HWND 中绘制,因此它始终绘制在 WPF 元素之上。

    【讨论】:

      猜你喜欢
      • 2018-10-01
      • 1970-01-01
      • 2017-11-11
      • 2018-12-20
      • 2023-03-03
      • 2016-04-01
      • 2017-12-14
      • 1970-01-01
      • 2017-04-30
      相关资源
      最近更新 更多