Windows Phone7程序控件使用Tilt(倾斜)效果

Windows Phone7 模拟器自带的settings等应用的列表等控件, 点击时有Tilt倾斜的效果, 我们自己写的Demo默认控件是没有这种效果,显得风格与系统不一致,查了一msdn,发现这种效果叫Tilt,并且官方有一个demo:

倾斜特效(Tilt Effect)示例

Windows Phone 控件的倾斜特效(Tilt Effect)为您在普通的控件交互中提供了更加丰富的可视化反馈。当控件被触摸时,它提供了一个“倾斜”状的反馈。控件倾斜特效示例展示了如何在一个应用程序当中实现这种倾斜特效。有关更多如何在应用程序中增加倾斜特效的更多信息,请查看Control Tilt Effect for Windows Phone

下载示例


如何在自己的项目增加Tilt效果呢,可以看看这个

How to: Use the Control Tilt Effect for Windows Phone


其实就是以下几步:

1、在项目中增加  TiltEffect class ,可以从demo中直接复制文件

2、在xaml文件MainPage.xaml开头增加 红色的2句

<phone:PhoneApplicationPage 
    x:Class="HelloWorld.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:ControlTiltEffect"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    local:TiltEffect.IsTiltEnabled="True"

3、如果某个控件不想要Tilt效果,则设置 local:TiltEffect.SuppressTilt="True"

例如

<Button Content="Button (Suppressed)" Height="150" HorizontalAlignment="Left" Margin="37,0,0,161" VerticalAlignment="Bottom" Width="380" local:TiltEffect.SuppressTilt="True"/>


挺简单吧,如果还是不清楚自己好好看官方的英文文档吧

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

offbye

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值