设置 Grid 控件的下沉效果

设置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);
                    }
                });

 

posted @ 2012-04-05 11:32  博琼  阅读(440)  评论(0编辑  收藏  举报