简体   繁体   English

C#Windows Phone 8.1应用程序中的图像映射

[英]Image Map in C# Windows Phone 8.1 application

I am making a windows phone 8.1 application using C# and XAML and I want to implement an Image map. 我正在使用C#和XAML制作Windows Phone 8.1应用程序,并且想实现图像映射。 I know how to do it in HTML using img tag's usemap attribute, but how using C# and XAML? 我知道如何使用img标签的usemap属性在HTML中执行此操作,但是如何使用C#和XAML?

You want to do something like this: 您想做这样的事情:

<Canvas xmlns="http://schemas.microsoft.com/client/2007"     
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   Width="500" Height="500">
   <Canvas.Background>
    <ImageBrush ImageSource="yourBackgroundImage.jpg" Stretch="Fill"/>
  </Canvas.Background>

  <Rectangle Width="50" Height="25" Canvas.Top="100" Canvas.Left="100" />
  <Rectangle Width="100" Height="20" Canvas.Top="200" Canvas.Left="300" />
  <!-- etc -->
</Canvas>

The Canvas with a background image is analogous to your <img> and the set of Rectangle elements are similar to your <area> tags inside your <map> . 具有背景图像的Canvas类似于<img>并且Rectangle元素集类似于<map> <area>标签。 You can add events to the Rectangle for things like Tap , you could give them a Fill property to make them a given color, etc. 您可以为诸如Tap类的事件添加事件到Rectangle中,可以给它们提供Fill属性以使其具有给定的颜色,等等。

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

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