Windows Phone - Tilt effect on HubTile and other Controls

In this article I will talk about creating tilt effect in different control in Windows Phone. Implementing tilt effect on controls are easy but few controls like Hubtile, textblock don't create tilt effect itself. We need to little bit work around to achieve. In this article first we will look into how to create tilt effect on normal controls then we will discuss on how to put tilt effect on hubtile, textblock.


Let's write code:


Download Silverlight Windows Phone Toolkit


Step 1: Create a silverlight for Windows Phone project.


Step 2: Add reference of Microsoft.Phone.Controls.Toolkit.dll


Step 3: Add namespace of Microsoft.Phone.Controls.Toolkit in MainPage.xaml.


xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"


Step 4: Add below line in phone:PhoneApplicationPage element.


toolkit

:TiltEffect.IsTiltEnabled="True"

Step 5: Add a listbox and a button inside ContenPanel of MainPage.xaml.


<ListBox Margin="20,280,0,0" Height="80" FontSize="28" >
<ListBoxItem Content
="Item1"/>
<ListBoxItem Content
="Item2"/>
</ListBox>

<Button x:Name="tiltEffect" Margin="20,480,0,0" Height="80" Width="430" Content="Tilt" />

Step 5: Now run the application and on touch of listbox item and button you will notice tilt effect.


Step 6: To suppress tilt effect for a particular item of ListBox or control we can use below code.


toolkit

:TiltEffect.SuppressTilt="True"

Step 7: Now replace code of Step 5 with below code and run the application, the highlighted code will suppress the tilt effect.


<ListBox Margin="20,280,0,0" Height="80" FontSize="28" >
<ListBoxItem Content="Item1" toolkit:TiltEffect.SuppressTilt
="True"/>
<ListBoxItem Content
="Item2"/>
</ListBox>

<Button x:Name="tiltEffect" toolkit:TiltEffect.SuppressTilt="True" Margin="20,480,0,0" Height="80" Width="430" Content="Tilt" />

Step 8: Now add a hubtile, textblock and image inside ContentPanel of MainPage.xaml.


<

toolkit:HubTile Title="UnFreezed Title" Background="Maroon" x:Name="hubTile1" />

<

Image Source="/TestTilt.png" Margin="0" HorizontalAlignment="Left" Height="173" Width="173" VerticalAlignment="top"/>

<

TextBlock Text="Testing" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="100" Margin="200,-410,12,0" />

Step 9: Now run the application again and you will notice tile effect won't work for hubtile, image and textblock.


Let's implement tilt effect for hubtile, image and textblock.


Step 10: Now create a class TiltableControl (Highlighted) which in MainPage.xaml.cs above MainPage class.


namespace

Windows_Phone___Tile_Effect
{
public class TiltableControl :
Grid
{
}

public partial class MainPage : PhoneApplicationPage
{


Step 11: Add TiltableControl in TiltableItems like shown below in the MainPage constructor.


TiltEffect

.TiltableItems.Add(typeof(TiltableControl));

Step 12: Add namespace like below in MainPage.xaml.


xmlns:myTilt="clr-namespace:Windows_Phone___Tile_Effect"


Step 13: Now wrap the hubtile, textblock and image control created in Step 8 with TiltableControl.


<myTilt:TiltableControl>
<Image Source="/TestTilt.png" Margin="0" HorizontalAlignment="Left" Height="173" Width="173" VerticalAlignment
="top"/>
</myTilt:TiltableControl>

<myTilt:TiltableControl>
<TextBlock Text="Testing" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="100" Margin
="200,-410,12,0" />
</myTilt:TiltableControl>

<myTilt:TiltableControl>
<toolkit:HubTile Title="UnFreezed Title" Background="Maroon" x:Name
="hubTile1" />
</myTilt:TiltableControl>

Step 14: Now run the application, you will notice hubtile, image and textblock has tilteffect.


This ends the article of tilt effect in hubtile, image and other controls in Windows Phone.

Like us if you find this post useful. Thanks!

转载于:https://www.cnblogs.com/zziss/archive/2012/10/22/2734351.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值