快速浏览一下代码会发现它GMapControl
是一个ItemsContainer
.
您应该能够重新设置ItemsPanel
模板的样式并在IsManipulationEnabled
那里提供属性:
<g:GMapControl x:Name="Map" ...>
<g:GMapControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas IsManipulationEnabled="True" />
</ItemsPanelTemplate>
</g:GMapControl.ItemsPanel>
<!-- ... -->
此时,您需要连接Window
:
<Window ...
ManipulationStarting="Window_ManipulationStarting"
ManipulationDelta="Window_ManipulationDelta"
ManipulationInertiaStarting="Window_InertiaStarting">
并在后面的代码中提供适当的方法(无耻地窃取并改编自此 MSDN Walkthrough):
void Window_ManipulationStarting(
object sender, ManipulationStartingEventArgs e)
{
e.ManipulationContainer = this;
e.Handled = true;
}
void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
// uses the scaling value to supply the Zoom amount
this.Map.Zoom = e.DeltaManipulation.Scale.X;
e.Handled = true;
}
void Window_InertiaStarting(
object sender, ManipulationInertiaStartingEventArgs e)
{
// Decrease the velocity of the Rectangle's resizing by
// 0.1 inches per second every second.
// (0.1 inches * 96 pixels per inch / (1000ms^2)
e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0);
e.Handled = true;
}