全景视图Panorama 这里面最有意思的就是这个背景图片了。。会随着你的移动而移动,视觉效果非常的好,右边还会提示下一页的内容,当然这个内容展示就像一个圈一样,没有尽头。可以一直翻
1 <sc:Panorama Title="商场">
2 <sc:Panorama.Background>
3 <ImageBrush ImageSource="mm.jpg"></ImageBrush>
4 </sc:Panorama.Background>
5 <sc:PanoramaItem Header="电脑销售" >
6 <StackPanel>
7 <TextBlock>笔记本</TextBlock>
8 <TextBlock>台式机</TextBlock>
9 </StackPanel>
10 </sc:PanoramaItem>
11 <sc:PanoramaItem Header="手机销售" >
12 <StackPanel>
13 <TextBlock>HTC</TextBlock>
14 <TextBlock>苹果</TextBlock>
15 </StackPanel>
16 </sc:PanoramaItem>
17
18 </sc:Panorama>
枢轴视图Pivot的用法,类似于我们操作系统的菜单
1 <sc:Pivot>
2 <sc:PivotItem Header="电脑">
3 <StackPanel >
4 <TextBlock>笔记本</TextBlock>
5 <TextBlock>台式机</TextBlock>
6 </StackPanel>
7 </sc:PivotItem>
8 <sc:PivotItem Header="手机">
9 <StackPanel >
10 <TextBlock>HTC</TextBlock>
11 <TextBlock>苹果</TextBlock>
12 </StackPanel>
13 </sc:PivotItem>
14 </sc:Pivot>
ScrollViewer用于显示大内容,显示尺寸不够则可以通过滚动条控制。HorizontalScrollBarVisibility、VerticalScrollBarVisibility控制滚动条显示
1 <ScrollViewer Name="sv1" Height="300" Width="300">
2 <toolkit:WrapPanel Name="wp1">
3 <Button Content="1" Width="120"></Button>
4 <Button Content="1" Width="120"></Button>
5 <Button Content="1" Width="120"></Button>
6 <Button Content="1" Width="120"></Button>
7 <Button Content="1" Width="120"></Button>
8 <Button Content="1" Width="120"></Button>
9 </toolkit:WrapPanel>
10 </ScrollViewer>
如果我们想在用户拉到最底下时动态的更新新的数据,想微博那样一直往下拉,会加载新的内容,我们可以在下拉到底部的时候给控件注册个事件来达到我们的需求
1 ScrollViewerMonitor svm = new ScrollViewerMonitor(sv1);
2 svm.AtEnd += new EventHandler(svm_AtEnd);
3 }
4
5 void svm_AtEnd(object sender, EventArgs e)
6 {
7 for (int i=0; i < 10; i++)
8 {
9 Button btn = new Button();
10 btn.Content = Guid.NewGuid().ToString().Substring(0, 5);
11 wp1.Children.Add(btn);
12 }
13 }
下面是ScrollViewerMonitor类的内容,
动态监视scrollViewer.VerticalOffset的值当它超过本身的高度的时候就触发AtEnd 事件,我们可以在外部注册这个事件!
1 public class ScrollViewerMonitor
2 {
3 private ScrollViewer scrollViewer;
4
5 private static int index;
6
7 public ScrollViewerMonitor(ScrollViewer scrollViewer)
8 {
9 this.scrollViewer = scrollViewer;
10
11 var property = DependencyProperty.RegisterAttached("DependencyPropertyListener" + index++,
12 typeof(double), typeof(ScrollViewer), new PropertyMetadata(scrollViewerVerticalOffset_Changed));
13
14 Binding binding = new Binding("VerticalOffset") { Source = scrollViewer };
15 scrollViewer.SetBinding(property, binding);
16 }
17
18 public event EventHandler AtEnd;
19
20 private void scrollViewerVerticalOffset_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
21 {
22 bool atBottom = scrollViewer.VerticalOffset
23 >= scrollViewer.ScrollableHeight;
24
25 if (atBottom)
26 {
27 if (AtEnd != null)
28 {
29 AtEnd(this, EventArgs.Empty);
30 }
31 }
32 }
33 }