【发布时间】:2020-10-08 08:40:52
【问题描述】:
我正在尝试制作一个程序,您可以在其中使用 Bing 地图并在其上绘图。但是我遇到了一个问题,即“InkCanvas”位于地图上方,因此我无法在地图上移动或使用地图上的任何按钮。
这是 MainPage.xaml 代码:
<Page xmlns:my="using:Windows.UI.Xaml.Controls.Maps"
x:Class="Drawit4you.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Drawit4you"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="HeaderPanel" Orientation="Horizontal" Grid.Row="0">
<InkToolbar x:Name="inkToolbar"
VerticalAlignment="Top"
Margin="10,0,10,0"
TargetInkCanvas="{x:Bind inkCanvas}">
</InkToolbar>
</StackPanel>
<Grid Grid.Row="1">
<my:MapControl
x:Name="MyMap"
MapServiceToken="MY-TOKEN"
Style="AerialWithRoads"
ZoomInteractionMode="GestureAndControl"
TiltInteractionMode="GestureAndControl"
RotateInteractionMode="GestureAndControl"/>
<InkCanvas x:Name="inkCanvas" />
</Grid>
</Grid>
这是 MainPage.xaml.cs 代码:
using Windows.UI.Xaml.Controls;
namespace Drawit4you
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
inkCanvas.InkPresenter.InputDeviceTypes =
Windows.UI.Core.CoreInputDeviceTypes.Mouse |
Windows.UI.Core.CoreInputDeviceTypes.Pen;
}
}
}
有没有什么方法可以让我与地图和按钮进行交互,而无需绘制,然后通过单击按钮开始在地图上绘制?
【问题讨论】:
-
您是否尝试过设置IsHitTestVisible 属性?我假设这可以用来切换用户与任何给定
UIElement交互的能力。 -
我已经尝试在 MapControl 和 InkCanvas 上使用 IsHitTestVisible 并在 MainPaige.xaml.cs 中添加一些代码,但它似乎没有做任何事情。我可能做错了什么,但我不知道是什么?
-
对于
InkCanvas,您需要将IsHitTestVisible设置为false。这允许输入转到下面的元素,如Hit testing and input events 中所述。 -
(对不起,如果我不明白该怎么做,但我对 UWP 和这种编码完全陌生)好的,所以我尝试在 InkCanvas 中将 IsHitTestVisible 设置为 false 并尝试了一些不同的示例的代码。但是我在运行项目时看不到任何不同或变化。
标签: windows bing-maps inkcanvas