设置grid 控件的附加属性:

grid.SetValue(TiltEffect.IsTiltEnabledProperty , true);

 

参考:http://www.windowsphonegeek.com/articles/Silverlight-for-WP7-Toolkit-TiltEffect-in-depth

 

 

补充:首先需要设置父容器的 Effect 属性,把 Grid 项作为 xaml 页面中 ListBox 等容器的 ListboxItem

1)在页面中引入:

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

 

 <ScrollViewer x:Name="viewer_hot">
                        <Grid Margin="0,0,0,0" >
                            <ItemsControl  x:Name="listBox_Hot" 
                             Width="478" 
                             Margin="0">
                            </ItemsControl>
                        </Grid>
                    </ScrollViewer>

 

2)在 .cs 文件中遍历 列表,添加到 listBox_Hot 中:

Dispatcher.BeginInvoke(delegate
                {
                    foreach (Link link in hot.links)
                    {
                        //listBox_Hot.Items.Add(CreateParentGrid(link));
                        ListBoxItem item = new ListBoxItem();
                        item.Content = CreateParentGrid(link);
                        TiltEffect.SetIsTiltEnabled(item, true);
                        listBox_Hot.Items.Add(item);
                    }
                });

 

相关文章:

  • 2022-12-23
  • 2021-12-04
  • 2021-05-28
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-11-28
相关资源
相似解决方案