[英]TiltEffect on longListSelector Items, windows phone 8
This may sound really NOOBI! 这可能听起来真的NOOBI!
I have a LongListSelector
for showing some items in my app, and I wanted to add this cool effect called TiltEffect
to the items so they show some interaction as user taps on one of the them. 我有一个
LongListSelector
用于显示我的应用程序中的一些项目,我想将这个名为TiltEffect
酷效果添加到项目中,以便当用户点击其中一个项目时显示一些交互。
For that matter I searched the internet and came up with this link on MSDN and I have done as instructed there. 就此而言,我搜索了互联网并在MSDN上找到了这个链接,我按照那里的指示完成了。 I downloaded the code sample, added the discussed class to my project and in the
MainPage.xaml
I added the following lines: 我下载了代码示例,将讨论过的类添加到我的项目中,并在
MainPage.xaml
添加了以下行:
xmlns:local="clr-namespace:MyNamespace"
local:TiltEffect.IsTiltEnabled="True"
alnd also in the class TiltEffect.cs
I added LongListSelector
as a TiltableItem
like this: 另外在类
TiltEffect.cs
我添加了LongListSelector
作为TiltableItem
如下所示:
static TiltEffect()
{
// The tiltable items list.
TiltableItems = new List<Type>() { typeof(ButtonBase), typeof(ListBoxItem), typeof(LongListSelector),};
UseLogarithmicEase = false;
}
Now the problem is that when any of the items on the LongListSelector
is tapped, the whole LongListSelector
tilts instead of only the tapped item. 现在的问题是,当点击
LongListSelector
上的任何项目时,整个LongListSelector
倾斜而不是仅倾斜项目。 please help! 请帮忙!
I found the answer to my problem here I wrapped my DataTempalte
in a ListBoxItem
, now it looks like this: 我在这里找到了问题的答案,我将
DataTempalte
包装在ListBoxItem
,现在看起来像这样:
<phone:LongListSelector x:Name="MyLongListSelector"
Margin="0,0,0,0"
ItemsSource="{Binding My_Items}"
SelectionChanged="MyLongListSelector_SelectionChanged">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<ListBoxItem >
<StackPanel Margin="0,0,0,7" local:TiltEffect.IsTiltEnabled="True" MinWidth="460">
<StackPanel.Background>
<ImageBrush Stretch="Fill" ImageSource="/Assets/Photos/items.png"/>
</StackPanel.Background>
<TextBlock Text="{Binding Title}"
TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"
TextAlignment="Center"
Margin="0, 5, 0, 15" FontFamily="Assets/Fonts/BNazanin.ttf#B Nazanin"/>
</StackPanel>
</ListBoxItem>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
你可以尝试将你用作跳转列表项的类型添加到可倾斜项集合而不是LongListSelector。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.