全景視圖Panorama 這里面最有意思的就是這個背景圖片了。。會隨著你的移動而移動,視覺效果非常的好,右邊還會提示下一頁的內(nèi)容,當然這個內(nèi)容展示就像一個圈一樣,沒有盡頭。可以一直翻
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的用法,類似于我們操作系統(tǒng)的菜單
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用于顯示大內(nèi)容,顯示尺寸不夠則可以通過滾動條控制。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>
如果我們想在用戶拉到最底下時動態(tài)的更新新的數(shù)據(jù),想微博那樣一直往下拉,會加載新的內(nèi)容,我們可以在下拉到底部的時候給控件注冊個事件來達到我們的需求
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類的內(nèi)容,
動態(tài)監(jiān)視scrollViewer.VerticalOffset的值當它超過本身的高度的時候就觸發(fā)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 }