是否有这样做的XAML图像映射的方法吗? [英] Is there any way of doing an image map on XAML?

查看:101
本文介绍了是否有这样做的XAML图像映射的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个使用C#和XAML一个Windows 8应用程序。

I want to create a Windows 8 application using C# and XAML.

我想有它的不同部位被点击,以同样的方式一个形象,你可以在HTML的图像映射元素。

I want to have an image with different parts of it being clickable, the same way that you can with the imagemap element in HTML.

有可能与单个图像这样做的一个方式,但将是非常困难的它们正确定位。

There might be a way of doing this with individual images but it would be very difficult to position them correctly.

那么,这可能使图像点击在XAML?

So is it possible to make images clickable in XAML?

推荐答案

简单的概念,例如,在短短的XAML ...

Simple Concept Example in just xaml...

添加命名空间;)

 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
 xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"


<Grid Height="300" Width="300">
       <Grid.Background>
         <Image/> <!-- Add your image source here, 
                       you dont want to know the picture I was going to put :) -->
       </Grid.Background>

       <Rectangle Height="20" Width="20" Stroke="Red" StrokeThickness="2" Margin="60,120">
         <i:Interaction.Triggers>
           <!-- Couldn't recall if its "Click" event or "MouseLeftButtonDown" -->
             <i:EventTrigger EventName="MouseLeftButtonDown">
                <ei:ChangePropertyAction TargetName="Blah"
                                         PropertyName="Visibility"
                                         Value="Visible" />
             </i:EventTrigger>
         </i:Interaction.Triggers>
       </Rectangle>

       <TextBlock Text="Whoa Dude, Where's my click?" x:Name="Blah" FontSize="50" Visibility="Collapsed"/>

    </Grid>

这篇关于是否有这样做的XAML图像映射的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆